Skip to content

Commit

Permalink
Merge pull request #153 from antpaw/reverse-animation-dissolve
Browse files Browse the repository at this point in the history
add reverse animation option to UIDissolve
  • Loading branch information
mob-sakai authored Mar 10, 2019
2 parents 4ceb771 + 24a3cbb commit bf87aeb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected override void OnEnable()
_spColorMode = serializedObject.FindProperty("m_ColorMode");
_spNoiseTexture = serializedObject.FindProperty("m_NoiseTexture");
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
_spReverseAnimation = serializedObject.FindProperty("m_ReverseAnimation");
var player = serializedObject.FindProperty("m_Player");
_spPlay = player.FindPropertyRelative("play");
_spDuration = player.FindPropertyRelative("duration");
Expand Down Expand Up @@ -118,6 +119,7 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(_spLoop);
EditorGUILayout.PropertyField(_spLoopDelay);
EditorGUILayout.PropertyField(_spUpdateMode);
EditorGUILayout.PropertyField(_spReverseAnimation);

// Debug.
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
Expand Down Expand Up @@ -164,6 +166,7 @@ public override void OnInspectorGUI()
SerializedProperty _spNoiseTexture;
SerializedProperty _spEffectArea;
SerializedProperty _spKeepAspectRatio;
SerializedProperty _spReverseAnimation;
SerializedProperty _spPlay;
SerializedProperty _spLoop;
SerializedProperty _spLoopDelay;
Expand Down
18 changes: 17 additions & 1 deletion Assets/Coffee/UIExtensions/UIEffect/Scripts/UIDissolve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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;
Expand Down Expand Up @@ -367,7 +370,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()
Expand Down

0 comments on commit bf87aeb

Please sign in to comment.