From 7724d5a9edda5b47c5861b64ec502d6460d5eebd Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Sat, 6 Oct 2018 17:05:49 +0900 Subject: [PATCH] close #132; UITransitionEffect: Add Show/Hide method --- .../UIEffect/Scripts/UITransitionEffect.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Assets/Coffee/UIExtensions/UIEffect/Scripts/UITransitionEffect.cs b/Assets/Coffee/UIExtensions/UIEffect/Scripts/UITransitionEffect.cs index e40a32c..5141b29 100644 --- a/Assets/Coffee/UIExtensions/UIEffect/Scripts/UITransitionEffect.cs +++ b/Assets/Coffee/UIExtensions/UIEffect/Scripts/UITransitionEffect.cs @@ -52,6 +52,8 @@ namespace Coffee.UIExtensions [Tooltip("Dissolve edge color.")] [SerializeField] [ColorUsage(false)] Color m_DissolveColor = new Color(0.0f, 0.25f, 1.0f); + [Header("Effect Runner")] + [SerializeField] EffectRunner m_Runner; //################################ // Public Members. @@ -168,6 +170,24 @@ namespace Coffee.UIExtensions } } + /// + /// Show transition. + /// + public void Show() + { + _runner.loop = false; + _runner.Play(f => effectFactor = f); + } + + /// + /// Hide transition. + /// + public void Hide() + { + _runner.loop = false; + _runner.Play(f => effectFactor = 1 - f); + } + /// /// Modifies the material. /// @@ -252,11 +272,26 @@ namespace Coffee.UIExtensions //################################ // Protected Members. //################################ + + /// + /// This function is called when the object becomes enabled and active. + /// + protected override void OnEnable() + { + base.OnEnable(); + _runner.OnEnable(null); + _runner.loop = false; + } + + /// + /// This function is called when the behaviour becomes disabled () or inactive. + /// protected override void OnDisable() { MaterialCache.Unregister(_materialCache); _materialCache = null; base.OnDisable(); + _runner.OnDisable(); } protected override void SetDirty() @@ -288,5 +323,7 @@ namespace Coffee.UIExtensions // Private Members. //################################ MaterialCache _materialCache = null; + + EffectRunner _runner{get{ return m_Runner ?? (m_Runner = new EffectRunner());}} } }