Author Topic: Setting properties when using NGUITools.Addchild(parent, prefab)  (Read 2915 times)

Astrydax

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
As an example scenario, say I have a prefab called newLoot with a UILabel component.

After Calling NGUITools.AddChild(treasureChest, newLoot);

How would I set the newLoot.UILabel.text for only that instance of the object?

I'm kind of an amateur programmer and might be going about this the wrong way entirely.

EDIT: I suppose what I'm asking is, how can I make a custom gameobject constructor that works with NGUITools.AddChild

I read this post from Unity Answers http://answers.unity3d.com/questions/563786/class-constructor-on-instantiated-objects.html
But I imagine this only works when using Instantiate()
« Last Edit: September 01, 2016, 01:48:12 AM by Astrydax »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Setting properties when using NGUITools.Addchild(parent, prefab)
« Reply #1 on: September 03, 2016, 01:55:03 AM »
AddChild returns a game object. You can work with it like any other game object by using GetComponent.