Skip to content

Commit

Permalink
close #132; UITransitionEffect: Add Show/Hide method
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Oct 6, 2018
1 parent 3215160 commit 7724d5a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Assets/Coffee/UIExtensions/UIEffect/Scripts/UITransitionEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public enum EffectMode
[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.
Expand Down Expand Up @@ -168,6 +170,24 @@ public Color dissolveColor
}
}

/// <summary>
/// Show transition.
/// </summary>
public void Show()
{
_runner.loop = false;
_runner.Play(f => effectFactor = f);
}

/// <summary>
/// Hide transition.
/// </summary>
public void Hide()
{
_runner.loop = false;
_runner.Play(f => effectFactor = 1 - f);
}

/// <summary>
/// Modifies the material.
/// </summary>
Expand Down Expand Up @@ -252,11 +272,26 @@ public override void ModifyMesh(VertexHelper vh)
//################################
// Protected Members.
//################################

/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_runner.OnEnable(null);
_runner.loop = false;
}

/// <summary>
/// This function is called when the behaviour becomes disabled () or inactive.
/// </summary>
protected override void OnDisable()
{
MaterialCache.Unregister(_materialCache);
_materialCache = null;
base.OnDisable();
_runner.OnDisable();
}

protected override void SetDirty()
Expand Down Expand Up @@ -288,5 +323,7 @@ protected override Material GetMaterial()
// Private Members.
//################################
MaterialCache _materialCache = null;

EffectRunner _runner{get{ return m_Runner ?? (m_Runner = new EffectRunner());}}
}
}

0 comments on commit 7724d5a

Please sign in to comment.