hello,
I want to first of all congratulate you for the plugin, really well done.
I have a small problem that I think is not really Ngui's fault.
I want to use ReadPixels () to save a screenshot of a portion of the screen that fits exactly with a UITexture of Ngui.
This is the code I used:
Bounds b = NGUIMath.CalculateAbsoluteWidgetBounds(main_foto_texture.transform);
Rect r = BoundsToScreenRect(b);
snap.ReadPixels(r, 0, 0);
snap.Apply();
where main_foto_texture is a UITexture.
The function:
public Rect BoundsToScreenRect(Bounds bounds)
{
// Get mesh origin and farthest extent (this works best with simple convex meshes)
Vector3 origin
= uiCamera
.WorldToScreenPoint(new Vector3
(bounds
.min.x, bounds
.max.y, 0f
)); Vector3 extent
= uiCamera
.WorldToScreenPoint(new Vector3
(bounds
.max.x, bounds
.min.y, 0f
)); Debug.Log("Origin: " + origin + " extent: " + extent);
return new Rect
(origin
.x, Screen
.height - origin
.y, extent
.x - origin
.x, origin
.y - extent
.y); }
I attach the result... is not big enough and the buttons should'nt be shown (the UITexture is gray and ends over them).
The only camera in the scene is the UI camera.
I tried to use relativewidgetbounds without casting it to screen coordinates but it gives me some negative value that I think are not correct (how can a screen coordinate be negative?)
Could you please help me? Thank you in advance! And sorry for my english... ^^
Matteo