Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: 1bol62pka90s02ga on April 01, 2013, 03:03:19 AM

Title: how to display guiTexture in NGUI
Post by: 1bol62pka90s02ga on April 01, 2013, 03:03:19 AM
I has create gameobject and add script to camera but not show if in project I add UI of NGUI

void Start()
    {
for (int i = 0; i < maxLevel; i++)
        {
var obj = new GameObject("Block" + i);
            obj.AddComponent("GUITexture");
            obj.AddComponent("BlockDrag");
            obj.AddComponent("AudioSource");   
            obj.transform.localScale = Vector3.one;
listBlock.Add(obj);
}
}
void OnGUI(){

foreach (var x in listBlock)
        {           
            x.BlockObject.guiTexture.pixelInset = x.BlockRect;
            x.BlockObject.guiTexture.texture = GetBlockColorById(x.BlockColorId).Texture2D;
        }
    }

see my picture: (http://i.imgur.com/3zr5MhI.png)
can anyone see where I am going wrong?
Title: Re: how to display guiTexture in NGUI
Post by: FredericRP on April 01, 2013, 03:21:25 AM
I don't understand why you try to display a GUITexture using NGUI, you should use UISprite instead.
If you absolutely want a GUITexture, ensure that it's on the same layer as the Camera (may be "UI" instead of "Default")
Title: Re: how to display guiTexture in NGUI
Post by: 1bol62pka90s02ga on April 01, 2013, 03:51:01 AM
i need create dynamic gameobject to AddComponent and color gameobject will be change  :'(
this is screen before add UI NGUI:
(http://i.imgur.com/lB8uboC.png)

after add: (http://i.imgur.com/o12SZ7P.png)

i found gameobject (block) but it's behind because have 2 camera, how to bring to top @@
Title: Re: how to display guiTexture in NGUI
Post by: ArenMook on April 01, 2013, 06:06:56 AM
GUITexture and OnGUI != NGUI. You need to consult Unity's documentation instead.
Title: Re: how to display guiTexture in NGUI
Post by: Nicki on April 01, 2013, 07:23:36 AM
They are two entirely different systems.  You can recreate what GUITexture does by using NGUI's UITexture.