Author Topic: one way to call the uiwidget  (Read 4571 times)

reptilebeats

  • Guest
one way to call the uiwidget
« on: July 16, 2012, 05:58:49 PM »
hey quick question is their a way to call the UIWidget to be disabled or enabled without having to define what it is,

so instead of using gameObject.Find("cube").getcomponent(UILabel).enabled =true;

i could use gameObject.find("Cube").getcomponent(ui).enabled = true;

so basically one word for any uiwidget placed in a panel to make life easier a bit like the getcomponent.collider

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: one way to call the uiwidget
« Reply #1 on: July 16, 2012, 06:40:26 PM »
All UI components derive from UIWidget, but you can't just say "disable all widgets". There is no such functionality in Unity. Instead you can GetComponentsInChildren<UIWidget>(), then foreach through them and enable = false on each of them.

reptilebeats

  • Guest
Re: one way to call the uiwidget
« Reply #2 on: July 16, 2012, 06:51:25 PM »
yh thats what i have a simple loop to go through each one, but when i used UIWidget enabled == false worked fine but when enabled == true, it comes up saying guitexture was not found.

im switching my old unity gui to ngui so something must be tagged wrong, or theres something in my code thats mucking it up. just wanted to check that it is UIWidget and not something else before i started looking

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: one way to call the uiwidget
« Reply #3 on: July 16, 2012, 07:24:24 PM »
GUITexture is a Unity class, not an NGUI class.

UITexture is an NGUI class.

reptilebeats

  • Guest
Re: one way to call the uiwidget
« Reply #4 on: July 16, 2012, 07:39:52 PM »
yh exactly thats why i was getting confused, as the code would work if i didnt use UIWidget but used UILabel instead.

i think i found out what it was though, i had a guitexture not showing as i deleted the texture on another level, and i haven't been on this level for a long time so i forgot it was there.