void Awake() { //if (gameObject.activeInHierarchy) Visible = true; XmlLayoutTimer.DelayedCall(0, () => { if (gameObject.activeInHierarchy) { Visible = true; } }, this); }
void Awake() { m_awake = true; if (Application.isPlaying) { if (PreloadXmlLayoutCache) { HandlePreload(); } if (ForceRebuildOnAwake) { if (XmlFile != null && ForceReloadXmlFileOnAwake) { ReloadXmlFile(); } else { RebuildLayout(true); } } } #if UNITY_EDITOR if (!Application.isPlaying) { if (XmlFile != null) { if (Xml != XmlFile.text) { Debug.Log("[XmlLayout] : '" + XmlFile.name + "' has changed - reloading file and rebuilding layout."); ReloadXmlFile(); // Calling MarkSceneDirty here doesn't seem to work, but delaying the call to the end of the frame does XmlLayoutTimer.AtEndOfFrame(() => UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(this.gameObject.scene), this); } } } #endif if (Application.isPlaying && !ForceRebuildOnAwake) { SetupElementEventHandlers(); if (XmlLayoutController != null) { XmlLayoutTimer.DelayedCall(0.1f, () => XmlLayoutController.LayoutRebuilt(ParseXmlResult.Changed), this); } } IsReady = true; }
protected IEnumerator PlayShowAnimation(ShowAnimation animation, Action onCompleteCallback = null) { // Don't start animating if we're already animating (wait for the animation to finish first) while (_IsAnimating) { yield return(new WaitForEndOfFrame()); } _IsAnimating = true; if (!xmlLayout.IsReady) { yield return(new WaitForEndOfFrame()); } if (ShowAnimationDelay > 0) { CanvasGroup.alpha = 0; yield return(new WaitForSeconds(ShowAnimationDelay)); } CanvasGroup.alpha = DefaultOpacity; CanvasGroup.blocksRaycasts = true; if (animation.IsSlideAnimation()) { m_Animator.enabled = false; yield return(PlaySlideInAnimation(animation)); } else { m_Animator.enabled = true; m_Animator.speed = 0.25f / AnimationDuration; m_Animator.Play(animation.ToString()); var delay = m_Animator.GetCurrentAnimatorStateInfo(0).length / m_Animator.speed; // If we disable the animator immediately after the animation is complete, things get a bit wonky XmlLayoutTimer.DelayedCall(delay, () => { m_Animator.enabled = false; }, this); yield return(new WaitForSeconds(delay * 0.25f)); } _IsAnimating = false; StartCoroutine(WaitForShowAnimationToComplete(onCompleteCallback)); }