From 3589a45b468e625eb696cb7008ba6b1a197c89da Mon Sep 17 00:00:00 2001 From: Anton Pawlik Date: Sun, 10 Mar 2019 12:41:42 +0100 Subject: [PATCH] add reverse animation option to UIDissolve --- .../Scripts/Editor/UIDissolveEditor.cs | 3 +++ .../UIEffect/Scripts/UIDissolve.cs | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIDissolveEditor.cs b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIDissolveEditor.cs index ec043d5a..d03d37bb 100644 --- a/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIDissolveEditor.cs +++ b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIDissolveEditor.cs @@ -31,6 +31,7 @@ protected void OnEnable() _spNoiseTexture = serializedObject.FindProperty("m_NoiseTexture"); _spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio"); var player = serializedObject.FindProperty("m_Player"); + _spReverseAnimation = serializedObject.FindProperty("m_ReverseAnimation"); _spDuration = player.FindPropertyRelative("duration"); _spUpdateMode = player.FindPropertyRelative("updateMode"); } @@ -74,6 +75,7 @@ public override void OnInspectorGUI() //================ GUILayout.Space(10); EditorGUILayout.LabelField("Effect Player", EditorStyles.boldLabel); + EditorGUILayout.PropertyField(_spReverseAnimation); EditorGUILayout.PropertyField(_spDuration); EditorGUILayout.PropertyField(_spUpdateMode); @@ -109,6 +111,7 @@ public override void OnInspectorGUI() SerializedProperty _spNoiseTexture; SerializedProperty _spEffectArea; SerializedProperty _spKeepAspectRatio; + SerializedProperty _spReverseAnimation; SerializedProperty _spDuration; SerializedProperty _spUpdateMode; } diff --git a/Assets/Coffee/UIExtensions/UIEffect/Scripts/UIDissolve.cs b/Assets/Coffee/UIExtensions/UIEffect/Scripts/UIDissolve.cs index c8afef8d..afaf6af2 100644 --- a/Assets/Coffee/UIExtensions/UIEffect/Scripts/UIDissolve.cs +++ b/Assets/Coffee/UIExtensions/UIEffect/Scripts/UIDissolve.cs @@ -49,6 +49,9 @@ public class UIDissolve : UIEffectBase [Header("Effect Player")] [SerializeField] EffectPlayer m_Player; + [HideInInspector] + [SerializeField] bool m_ReverseAnimation = false; + #pragma warning disable 0414 [Obsolete][HideInInspector] [SerializeField][Range(0.1f, 10)] float m_Duration = 1; @@ -352,7 +355,20 @@ public void Stop() protected override void OnEnable() { base.OnEnable(); - _player.OnEnable(f => effectFactor = f); + if (m_ReverseAnimation) + { + _player.OnEnable((f) => + { + effectFactor = 1f - f; + }); + } + else + { + _player.OnEnable((f) => + { + effectFactor = f; + }); + } } protected override void OnDisable()