Author Topic: GameObject to UIButton?  (Read 1607 times)

Chaosgod_Espér

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 28
    • View Profile
GameObject to UIButton?
« on: December 09, 2012, 07:23:05 PM »
hi there..

i´m creating Buttons at runtime with:
  1. NGUITools.AddChild

problem now..

i want to set .isEnabled to false, for each created Button.
But this needs a UIButton..


Question:
how to set a UIButton from a GameObject?

LIKE:
  1. ButtonBlocksForeground = NGUITools.AddChild(MainUI_Object, prev_ButtonBlocksForeground);
  2. UIButton Button_BlocksForeground_UI = ButtonBlocksForeground as UIButton;
  3.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GameObject to UIButton?
« Reply #1 on: December 09, 2012, 09:08:33 PM »
Use GetComponent<UIButton>(). Check Unity's documentation -- this is just about the most basic and important thing to learn when starting with Unity.