Author Topic: how to display guiTexture in NGUI  (Read 7095 times)

1bol62pka90s02ga

  • Guest
how to display guiTexture in NGUI
« 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:
can anyone see where I am going wrong?

FredericRP

  • Guest
Re: how to display guiTexture in NGUI
« Reply #1 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")

1bol62pka90s02ga

  • Guest
Re: how to display guiTexture in NGUI
« Reply #2 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:


after add:

i found gameobject (block) but it's behind because have 2 camera, how to bring to top @@
« Last Edit: April 01, 2013, 05:07:50 AM by 1bol62pka90s02ga »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: how to display guiTexture in NGUI
« Reply #3 on: April 01, 2013, 06:06:56 AM »
GUITexture and OnGUI != NGUI. You need to consult Unity's documentation instead.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: how to display guiTexture in NGUI
« Reply #4 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.