Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Astrydax on August 31, 2016, 08:48:27 PM

Title: Setting properties when using NGUITools.Addchild(parent, prefab)
Post by: Astrydax on August 31, 2016, 08:48:27 PM
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()
Title: Re: Setting properties when using NGUITools.Addchild(parent, prefab)
Post by: ArenMook 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.