1
NGUI 3 Support / Convert UISprite to Texture2D
« on: March 22, 2014, 06:31:32 AM »
Hi,
I'm having a bit of trouble converting UISprite to Texture2D
I only want the selected sprite to be converted to the Texture2D and not the whole thing
I have done the following so far:
Can someone please tell me what I am doing wrong please?
I'm having a bit of trouble converting UISprite to Texture2D
I only want the selected sprite to be converted to the Texture2D and not the whole thing
I have done the following so far:
- UIAtlas atlas = objectWithSprite.GetComponent<UISprite>().atlas;
- UISpriteData sprite = objectWithSprite.GetComponent<UISprite>().GetAtlasSprite();
- Texture2D atlasTexture = atlas.spriteMaterial.mainTexture as Texture2D;
- Rect uv0 = NGUIMath.ConvertToTexCoords(outer, atlasTexture.width, atlasTexture.height);
- tex.uvRect = uv0;
- Texture2D t = tex.mainTexture;
Can someone please tell me what I am doing wrong please?
