Hello, I have a very simple Icon prefab, which is just a gameObject with a UISprite script attached to it. It has a scale of 1,1,1.
I instantiate it dynamically:
private void InitIcon(Texture t)
{
GameObject go = NGUITools.AddChild(gameObject, inventory.iconTemplate);
icon = go.GetComponent<UISprite>();
icon.spriteName = texture.name;
}
And then I need to get its size in pixels, which should be about (0.8, 0.

so I use:
bounds = NGUIMath.CalculateAbsoluteWidgetBounds(trans);
var sMax = cam.WorldToScreenPoint(bounds.max);
var sMin = cam.WorldToScreenPoint(bounds.min);
return sMax - sMin;
This has worked for me very well, but for some reason, in this situation, it's not working right, it's giving me the same bounds.Min and bounds.Max, so bounds.Size is (0, 0, 0) - See attachment.
Any idea why? I really want to use this method - Thanks.