Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: P15Studios on October 01, 2013, 12:12:27 AM
-
I have a progress bar that progresses on an action. When the action is done, I setActive(false) the Anchor that it's in. Then, the progress bar won't go away. The only way to get it to go away is to restart Unity. I set the anchor to inactive and nothing helps. Is this common? Am I'm doing something silly?
-
No, it's not normal. You need to provide more details to go on. Version of NGUI, version of Unity, what you use to disable it (Unity's functionality or NGUITools?), whether you disable the game object or just the UIAnchor component, etc.
-
4.2.1f4 Pro Unity
NGUI 2.7
I get access to my anchor and I disable it. I am doing this for a bunch of other things in NGUI ann never have a problem, this is the first I've seen it.
On Start:
this.pausedAnchor = GameObject.Find("PausedAnchor");
OnPauseGame:
this.pausedAnchor.SetActive(true);
OnResumeGame:
this.pausedAnchor.SetActive(false);
The anchor is set up like this:
Anchor
Panel
Sprite with animation from right to left
Sprite with animation from left to right
Button
Button
Button
ProgressBar
Thanks for the help!
-
SetActive(true) in Unity enables children before enabling parents, which is a problem. You need to use NGUITools.SetActive instead.
-
Followed your advice, which totally makes sense. However, the same problem still happens. I even tried using the SetActiveChildren, Self and just SetActive.
When a character collides with a cube, I want to pop up the progress bar and have it at 0.0. When the character presses "y". the slider should go from 0.0 - 1.0. If the character stops colliding, the slider should fall back to 0.0 and disappear. If the user lets go of Y before the slider hits 1.0, I want to reset it to 0.0 and then disappear. If the slider hit's 1.0. I want to reset it to 0.0 and make it disappear.
Stack trace below.
Destroying GameObjects immediately is not permitted during physics trigger/contact, animation event callbacks or OnValidate. You must use Destroy instead.
UnityEngine.Object:DestroyImmediate(Object)
NGUITools:DestroyImmediate(Object) (at Assets/Plugins/NGUI/Internal/NGUITools.cs:514)
UIPanel:OnDisable() (at Assets/Plugins/NGUI/UI/UIPanel.cs:705)
UnityEngine.GameObject:SetActive(Boolean)
NGUITools:SetActiveSelf(GameObject, Boolean) (at Assets/Plugins/NGUI/Internal/NGUITools.cs:669)
AmountStolen:OnTriggerStay(Collider) (at Assets/Scripts/InGameHUD/Amount.js:53)
-
Yeah, you can't disable UI elements from a physics callback. You need to delay the action by starting a coroutine.