mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-19 17:22:37 +08:00
@@ -22,6 +22,7 @@ namespace Coffee.UIEffects.Editors
|
||||
private SerializedProperty _updateMode;
|
||||
private SerializedProperty _wrapMode;
|
||||
private SerializedProperty _onComplete;
|
||||
private SerializedProperty _onChangedRate;
|
||||
private bool _isPlaying = false;
|
||||
private double _lastTime;
|
||||
|
||||
@@ -40,6 +41,7 @@ namespace Coffee.UIEffects.Editors
|
||||
_wrapMode = serializedObject.FindProperty("m_WrapMode");
|
||||
_updateMode = serializedObject.FindProperty("m_UpdateMode");
|
||||
_onComplete = serializedObject.FindProperty("m_OnComplete");
|
||||
_onChangedRate = serializedObject.FindProperty("m_OnChangedRate");
|
||||
|
||||
EditorApplication.update += UpdateTweeners;
|
||||
}
|
||||
@@ -54,6 +56,12 @@ namespace Coffee.UIEffects.Editors
|
||||
Profiler.BeginSample("(UIE)[UIEffectTweener] OnInspectorGUI");
|
||||
serializedObject.UpdateIfRequiredOrScript();
|
||||
EditorGUILayout.PropertyField(_cullingMask);
|
||||
|
||||
if (0 != (_cullingMask.intValue & (int)UIEffectTweener.CullingMask.Event))
|
||||
{
|
||||
EditorGUILayout.PropertyField(_onChangedRate);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_direction);
|
||||
EditorGUILayout.PropertyField(_curve);
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ namespace Coffee.UIEffects
|
||||
[RequireComponent(typeof(UIEffectBase))]
|
||||
public class UIEffectTweener : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
public class TweenerEvent : UnityEvent<float>
|
||||
{
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum CullingMask
|
||||
{
|
||||
@@ -20,7 +25,8 @@ namespace Coffee.UIEffects
|
||||
Transition = 1 << 3,
|
||||
GradiationOffset = 1 << 5,
|
||||
GradiationRotation = 1 << 6,
|
||||
EdgeShiny = 1 << 8
|
||||
EdgeShiny = 1 << 8,
|
||||
Event = 1 << 31
|
||||
}
|
||||
|
||||
public enum UpdateMode
|
||||
@@ -54,7 +60,9 @@ namespace Coffee.UIEffects
|
||||
|
||||
[Tooltip("The culling mask of the tween.")]
|
||||
[SerializeField]
|
||||
private CullingMask m_CullingMask = (CullingMask)(-1);
|
||||
private CullingMask m_CullingMask = CullingMask.Tone | CullingMask.Color | CullingMask.Sampling |
|
||||
CullingMask.Transition | CullingMask.GradiationOffset |
|
||||
CullingMask.GradiationRotation | CullingMask.EdgeShiny;
|
||||
|
||||
[Tooltip("The direction of the tween.")]
|
||||
[SerializeField]
|
||||
@@ -114,6 +122,10 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
private UnityEvent m_OnComplete = new UnityEvent();
|
||||
|
||||
[Tooltip("Event to invoke when the rate was changed.")]
|
||||
[SerializeField]
|
||||
private TweenerEvent m_OnChangedRate = new TweenerEvent();
|
||||
|
||||
private bool _isPaused;
|
||||
private float _rate = -1;
|
||||
private float _time;
|
||||
@@ -183,6 +195,11 @@ namespace Coffee.UIEffects
|
||||
|
||||
var evaluatedRate = currentCurve.Evaluate(_rate);
|
||||
target.SetRate(evaluatedRate, cullingMask);
|
||||
|
||||
if (0 != (cullingMask & CullingMask.Event))
|
||||
{
|
||||
onChangedRate.Invoke(evaluatedRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,6 +336,11 @@ namespace Coffee.UIEffects
|
||||
/// </summary>
|
||||
public UnityEvent onComplete => m_OnComplete;
|
||||
|
||||
/// <summary>
|
||||
/// Event to invoke when the rate was changed.
|
||||
/// </summary>
|
||||
public TweenerEvent onChangedRate => m_OnChangedRate;
|
||||
|
||||
/// <summary>
|
||||
/// Is the tween playing?
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user