Support => NGUI 3 Support => Topic started by: Asse on December 04, 2013, 12:09:45 AM
Title: Flickering when calling SetActive() an GameObjects
Post by: Asse on December 04, 2013, 12:09:45 AM
Hey folks,
I get flickering when I call GameObject.SetActive(true/false) even so I call Refresh on the parent panel afterwards.
Sample project is attached.
Title: Re: Flickering when calling SetActive() an GameObjects
Post by: ArenMook on December 04, 2013, 03:03:41 PM
When asking for support, never post NGUI's copyrighted source code in its entirety. It's common sense. Use email instead. I ban people for this.
Title: Re: Flickering when calling SetActive() an GameObjects
Post by: ArenMook on December 04, 2013, 05:59:09 PM
Had a look at the provided project. Calling Refresh is not necessary, but calling CreatePanel() is, otherwise the addition of widgets to panels won't occur until the next time their Update() gets called, which may or may not be in the same frame. You should also use NGUITools.SetActive instead of Unity's method. Unity's method activates children before parents.
P.S. I've just added this CreatePanel broadcast to NGUITools.SetActive so starting with the next release you won't need to call it yourself.
Title: Re: Flickering when calling SetActive() an GameObjects
Post by: Asse on December 05, 2013, 03:52:20 AM
Nice, this also fixed my problem with UITextures rendering wrong texture! Hope the SendMessage call won't be to expensive when you integrate it in SetActive and it's used on several objects at once.
Title: Re: Flickering when calling SetActive() an GameObjects
Post by: Nicki on December 05, 2013, 04:45:40 AM
It costs a SendMessage to each child of the activatedGameObject, since that's essentially what BroadcastMessage does.
If you have many GameObjects under the activatedGameObject, or have many, many components on each of them, then it's costly. It's not free, but it won't normally kill you. ;)