Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: alexlange on October 25, 2012, 10:57:59 PM

Title: Need some advise about Instantiate/AddChild
Post by: alexlange on October 25, 2012, 10:57:59 PM
Hi guys
I'm going to build a embedded chat scene
---------------------------------------------------------
ScrollableMessages
      |---Message(prefab)
      |         |-- A Label and a sliced sprite
      |---Message(Clones)
---------------------------------------------------------
The program may call thousand times of NGUITools.AddChild().
Is AddChild equals to Instantiate? Will it cost too much?

Because I was told instantiate/destroy is very expensive,
and we'd better don't call it too many/often on mobile device.
People also suggest me to use a pool instead.

But I have no idea how to make it work with UITable/UIGrid :p
Title: Re: Need some advise about Instantiate/AddChild
Post by: ArenMook on October 26, 2012, 01:24:10 AM
Yes, AddChild does an Instantiate call. I suggest you cache these instead. Enabling / disabling them (and/or reusing them) instead will have the same effect, but will be faster.
Title: Re: Need some advise about Instantiate/AddChild
Post by: alexlange on October 26, 2012, 02:07:15 AM
Understand
Thank you Aren  :D