Author Topic: Dynamically creating a UIButton throws an exception  (Read 2402 times)

appminis-mike

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
Dynamically creating a UIButton throws an exception
« on: May 19, 2014, 10:21:28 PM »
I'm trying to create a UIButton at runtime:

  1. NGUITools.AddChild<UIButton>(parentObject);
  2.  

This throws an exception, as the TweenTarget is not set. I don't see a way to set it, though, as the AddChild call itself throws the exception.

Is there a way to create a new UIButton in a script without causing an exception?

Thank you.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically creating a UIButton throws an exception
« Reply #1 on: May 20, 2014, 01:00:02 PM »
parentObject.AddComponent<UIButton>();