diff --git a/Packages/src/Editor/Coffee.UIEffect.Editor.asmdef b/Packages/src/Editor/Coffee.UIEffect.Editor.asmdef index 91dcc4d..213eba3 100644 --- a/Packages/src/Editor/Coffee.UIEffect.Editor.asmdef +++ b/Packages/src/Editor/Coffee.UIEffect.Editor.asmdef @@ -3,7 +3,9 @@ "rootNamespace": "", "references": [ "GUID:6055be8ebefd69e48b49212b09b47b2f", - "GUID:735c8f008d0ad4caa9cdc4306f1c3042" + "GUID:735c8f008d0ad4caa9cdc4306f1c3042", + "GUID:f06555f75b070af458a003d92f9efb00", + "GUID:02f771204943f4a40949438e873e3eff" ], "includePlatforms": [ "Editor" @@ -24,6 +26,11 @@ "name": "com.unity.ugui", "expression": "2.0.0", "define": "TMP_ENABLE" + }, + { + "name": "com.unity.timeline", + "expression": "1.0.0", + "define": "TIMELINE_ENABLE" } ], "noEngineReferences": false diff --git a/Packages/src/Editor/Timeline.meta b/Packages/src/Editor/Timeline.meta new file mode 100644 index 0000000..f7b0dbc --- /dev/null +++ b/Packages/src/Editor/Timeline.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3150c4c70d45b46d389368100b181ee4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Editor/Timeline/TextPlayableAssetClipEditor.cs b/Packages/src/Editor/Timeline/TextPlayableAssetClipEditor.cs new file mode 100644 index 0000000..de684f4 --- /dev/null +++ b/Packages/src/Editor/Timeline/TextPlayableAssetClipEditor.cs @@ -0,0 +1,183 @@ +#if TIMELINE_ENABLE +using System; +using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEditor.Timeline; +using UnityEngine; +using UnityEngine.Timeline; + +namespace Coffee.UIEffects.Timeline +{ + public abstract class UIEffectClipEditor : ClipEditor + { + public override void DrawBackground(TimelineClip clip, ClipBackgroundRegion region) + { + var director = TimelineEditor.inspectedDirector; + if (!director) return; + + var viewDuration = region.endTime - region.startTime; + var inDuration = (float)Math.Max(clip.easeInDuration, clip.blendInDuration); + var outDuration = (float)Math.Max(clip.easeOutDuration, clip.blendOutDuration); + inDuration = 0 < inDuration ? Mathf.Max(inDuration - (float)region.startTime, 0) : 0f; + outDuration = 0 < outDuration ? Mathf.Max(outDuration - (float)(clip.duration - region.endTime), 0) : 0f; + + var p = region.position; + p.x += p.width * (float)(inDuration / viewDuration); + p.width -= p.width * (float)((inDuration + outDuration) / viewDuration); + + DrawBackground(p, clip); + } + + public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) + { + clip.displayName = ObjectNames.NicifyVariableName(track.GetType().Name.Replace("Track", "")); + if (clip.asset is UIEffectClip uiEffectClip) + { + uiEffectClip.timelineClip = clip; + } + + var floatClip = clip.asset as UIEffectFloatClip; + if (floatClip) + { + if (track is GradationRotationTrack || track is GradationOffsetTrack) + { + floatClip.m_Data.m_From = 0f; + floatClip.m_Data.m_Value = 0f; + } + } + } + + protected abstract void DrawBackground(Rect rect, TimelineClip clip); + } + + [CustomTimelineEditor(typeof(UIEffectFloatClip))] + public class UIEffectFloatClipEditor : UIEffectClipEditor + { + private static GUIStyle s_FromStyle; + private static GUIStyle s_ToStyle; + + protected override void DrawBackground(Rect rect, TimelineClip clip) + { + var asset = clip.asset as UIEffectFloatClip; + if (!asset) return; + + if (s_FromStyle == null) + { + s_FromStyle = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperLeft, fontSize = 9 }; + s_ToStyle = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperRight, fontSize = 9 }; + } + + var d = asset.m_Data; + if (d.m_Tween) + { + DrawLabelWithShadow(rect, asset.m_Data.m_From.ToString("F2"), s_FromStyle); + DrawLabelWithShadow(rect, asset.m_Data.m_Value.ToString("F2"), s_ToStyle); + } + else + { + DrawLabelWithShadow(rect, asset.m_Data.m_Value.ToString("F2"), s_FromStyle); + } + } + + private static void DrawLabelWithShadow(Rect position, string text, GUIStyle style) + { + GUI.color = Color.black; + EditorGUI.LabelField(position, text, style); + GUI.color = Color.white; + position.x -= 1f; + position.y -= 1f; + EditorGUI.LabelField(position, text, style); + } + } + + [CustomTimelineEditor(typeof(UIEffectColorClip))] + public class UIEffectColorClipEditor : UIEffectClipEditor + { + protected override void DrawBackground(Rect p, TimelineClip clip) + { + var asset = clip.asset as UIEffectColorClip; + if (!asset) return; + + var d = asset.m_Data; + if (d.m_Tween) + { + EditorGUIUtility.DrawColorSwatch(new Rect(p.x + 2, p.y, 8, 8), d.m_From); + EditorGUIUtility.DrawColorSwatch(new Rect(p.x + p.width - 8, p.y, 8, 8), d.m_Value); + } + else + { + EditorGUIUtility.DrawColorSwatch(new Rect(p.x + 2, p.y, 8, 8), d.m_Value); + } + } + } + + [CustomEditor(typeof(UIEffectClip<>), true)] + public class UIEffectClipAssetEditor : Editor + { + private SerializedProperty _tween; + private SerializedProperty _from; + private SerializedProperty _curve; + private SerializedProperty _value; + private FloatClipUsageAttribute _floatUsage; + private ColorClipUsageAttribute _colorUsage; + private GUIContent _label; + + private void OnEnable() + { + var data = serializedObject.FindProperty("m_Data"); + _tween = data.FindPropertyRelative("m_Tween"); + _from = data.FindPropertyRelative("m_From"); + _curve = data.FindPropertyRelative("m_Curve"); + _value = data.FindPropertyRelative("m_Value"); + + var clip = target as UIEffectClip; + var type = clip.timelineClip.GetParentTrack().GetType(); + _floatUsage = type.GetCustomAttribute(); + _colorUsage = type.GetCustomAttribute(); + _label = new GUIContent(ObjectNames.NicifyVariableName(type.Name).Replace(" Track", "")); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(_tween); + + if (_tween.boolValue) + { + EditorGUI.indentLevel++; + DrawProperty(_from, EditorGUIUtility.TrTempContent("From")); + EditorGUILayout.PropertyField(_curve); + EditorGUI.indentLevel--; + } + + DrawProperty(_value, _label); + serializedObject.ApplyModifiedProperties(); + } + + private void DrawProperty(SerializedProperty property, GUIContent label) + { + if (_floatUsage != null) + { + EditorGUILayout.Slider(property, _floatUsage.min, _floatUsage.max, label); + } + else if (property.propertyType == SerializedPropertyType.Color) + { + var hdr = UIEffectProjectSettings.useHdrColorPicker; + var alpha = _colorUsage?.alpha ?? true; + + EditorGUI.BeginChangeCheck(); + var color = EditorGUILayout.ColorField(label, property.colorValue, true, alpha, hdr); + if (EditorGUI.EndChangeCheck()) + { + property.colorValue = color; + } + } + else + { + EditorGUILayout.PropertyField(property, label); + } + } + } +} +#endif diff --git a/Packages/src/Editor/Timeline/TextPlayableAssetClipEditor.cs.meta b/Packages/src/Editor/Timeline/TextPlayableAssetClipEditor.cs.meta new file mode 100644 index 0000000..c96089b --- /dev/null +++ b/Packages/src/Editor/Timeline/TextPlayableAssetClipEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3d108727fec4d48d28c1609b01a3a8c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Coffee.UIEffect.asmdef b/Packages/src/Runtime/Coffee.UIEffect.asmdef index 30ae08d..bb54849 100644 --- a/Packages/src/Runtime/Coffee.UIEffect.asmdef +++ b/Packages/src/Runtime/Coffee.UIEffect.asmdef @@ -2,7 +2,8 @@ "name": "Coffee.UIEffect", "rootNamespace": "", "references": [ - "GUID:6055be8ebefd69e48b49212b09b47b2f" + "GUID:6055be8ebefd69e48b49212b09b47b2f", + "GUID:f06555f75b070af458a003d92f9efb00" ], "includePlatforms": [], "excludePlatforms": [], @@ -21,6 +22,11 @@ "name": "com.unity.ugui", "expression": "2.0.0", "define": "TMP_ENABLE" + }, + { + "name": "com.unity.timeline", + "expression": "1.0.0", + "define": "TIMELINE_ENABLE" } ], "noEngineReferences": false diff --git a/Packages/src/Runtime/Timeline.meta b/Packages/src/Runtime/Timeline.meta new file mode 100644 index 0000000..6c02aad --- /dev/null +++ b/Packages/src/Runtime/Timeline.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3278a8b3cb92d4cc69862f0d45f150ad +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/Base.meta b/Packages/src/Runtime/Timeline/Base.meta new file mode 100644 index 0000000..ed356ee --- /dev/null +++ b/Packages/src/Runtime/Timeline/Base.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 014b76346c11643a89303ed3b5681733 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/Base/UIEffectColorClip.cs b/Packages/src/Runtime/Timeline/Base/UIEffectColorClip.cs new file mode 100644 index 0000000..0ba703c --- /dev/null +++ b/Packages/src/Runtime/Timeline/Base/UIEffectColorClip.cs @@ -0,0 +1,44 @@ +#if TIMELINE_ENABLE +using System; +using System.ComponentModel; +using UnityEngine; + +namespace Coffee.UIEffects.Timeline +{ + [DisplayName("Clip")] + public class UIEffectColorClip : UIEffectClip + { + } + + [Serializable] + public class UIEffectColorBehaviour : UIEffectBehaviour, IGetValue + { + [ColorUsage(true, true)] + public Color m_Value = Color.white; + + [ColorUsage(true, true)] + public Color m_From = Color.white; + + public Color Get(float time) + { + return m_Tween + ? Color.Lerp(m_From, m_Value, m_Curve.Evaluate(time)) + : m_Value; + } + } + + public abstract class UIEffectColorMixerBehaviour : UIEffectMixerBehaviour + { + protected override Color Add(Color baseValue, Color value, float weight) + { + return baseValue + value * weight; + } + + protected override Color Lerp(Color defaultValue, Color value, float weight) + { + return Color.Lerp(defaultValue, value, weight); + } + } +} + +#endif diff --git a/Packages/src/Runtime/Timeline/Base/UIEffectColorClip.cs.meta b/Packages/src/Runtime/Timeline/Base/UIEffectColorClip.cs.meta new file mode 100644 index 0000000..86cdd02 --- /dev/null +++ b/Packages/src/Runtime/Timeline/Base/UIEffectColorClip.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0c402544dc0be48afa6e9d3eb88120be +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/Base/UIEffectFloat01Clip.cs b/Packages/src/Runtime/Timeline/Base/UIEffectFloat01Clip.cs new file mode 100644 index 0000000..a4f13cb --- /dev/null +++ b/Packages/src/Runtime/Timeline/Base/UIEffectFloat01Clip.cs @@ -0,0 +1,53 @@ +// #if TIMELINE_ENABLE +// using System; +// using System.ComponentModel; +// using UnityEngine; +// +// namespace Coffee.UIEffects.Timeline +// { +// [DisplayName("Clip")] +// public class UIEffectFloat01Clip : UIEffectClip +// { +// } +// +// // [Serializable] +// // public class UIEffectFloat01Behaviour : UIEffectFloatBehaviour +// // { +// // [Range(0, 1)] +// // public float m_Value = 1; +// // +// // [Range(0, 1)] +// // public float m_From = 1; +// // +// // protected override float from => m_From; +// // protected override float value => m_Value; +// // } +// +// // public class UIEffectFloatBehaviour : UIEffectBehaviour, IGetValue +// // { +// // protected virtual float value { get; } +// // protected virtual float from { get; } +// // +// // public float Get(float time) +// // { +// // return m_Tween +// // ? Mathf.Lerp(from, value, m_Curve.Evaluate(time)) +// // : value; +// // } +// // } +// // +// // public abstract class UIEffectFloatMixerBehaviour : UIEffectMixerBehaviour +// // { +// // protected override float Add(float baseValue, float value, float weight) +// // { +// // return baseValue + value * weight; +// // } +// // +// // protected override float Lerp(float defaultValue, float value, float weight) +// // { +// // return Mathf.Lerp(defaultValue, value, weight); +// // } +// // } +// } +// +// #endif diff --git a/Packages/src/Runtime/Timeline/Base/UIEffectFloat01Clip.cs.meta b/Packages/src/Runtime/Timeline/Base/UIEffectFloat01Clip.cs.meta new file mode 100644 index 0000000..b5c7c34 --- /dev/null +++ b/Packages/src/Runtime/Timeline/Base/UIEffectFloat01Clip.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: deea59e7cd34449c89e7c1f6438a5392 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/Base/UIEffectFloatClip.cs b/Packages/src/Runtime/Timeline/Base/UIEffectFloatClip.cs new file mode 100644 index 0000000..5a88cd7 --- /dev/null +++ b/Packages/src/Runtime/Timeline/Base/UIEffectFloatClip.cs @@ -0,0 +1,42 @@ +#if TIMELINE_ENABLE +using System; +using System.ComponentModel; +using UnityEngine; + +namespace Coffee.UIEffects.Timeline +{ + [DisplayName("Clip")] + public class UIEffectFloatClip : UIEffectClip + { + } + + [Serializable] + public class UIEffectFloatBehaviour : UIEffectBehaviour, IGetValue + { + public float m_Value = 1; + + public float m_From = 1; + + public float Get(float time) + { + return m_Tween + ? Mathf.Lerp(m_From, m_Value, m_Curve.Evaluate(time)) + : m_Value; + } + } + + public abstract class UIEffectFloatMixerBehaviour : UIEffectMixerBehaviour + { + protected override float Add(float baseValue, float value, float weight) + { + return baseValue + value * weight; + } + + protected override float Lerp(float defaultValue, float value, float weight) + { + return Mathf.Lerp(defaultValue, value, weight); + } + } +} + +#endif diff --git a/Packages/src/Runtime/Timeline/Base/UIEffectFloatClip.cs.meta b/Packages/src/Runtime/Timeline/Base/UIEffectFloatClip.cs.meta new file mode 100644 index 0000000..5ba7f99 --- /dev/null +++ b/Packages/src/Runtime/Timeline/Base/UIEffectFloatClip.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ffaa25511fc8148839e36bda4414e944 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/Base/UIEffectTimelineUtils.cs b/Packages/src/Runtime/Timeline/Base/UIEffectTimelineUtils.cs new file mode 100644 index 0000000..818496b --- /dev/null +++ b/Packages/src/Runtime/Timeline/Base/UIEffectTimelineUtils.cs @@ -0,0 +1,178 @@ +#if TIMELINE_ENABLE +using System; +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace Coffee.UIEffects.Timeline +{ + [AttributeUsage(AttributeTargets.Class)] + public class FloatClipUsageAttribute : PropertyAttribute + { + public readonly float min; + public readonly float max; + public readonly float defaultValue; + + public FloatClipUsageAttribute(float min, float max, float defaultValue = 0f) + { + this.min = min; + this.max = max; + this.defaultValue = defaultValue; + } + } + + [AttributeUsage(AttributeTargets.Class)] + public class ColorClipUsageAttribute : PropertyAttribute + { + public readonly bool alpha; + + public ColorClipUsageAttribute(bool alpha) + { + this.alpha = alpha; + } + } + + public interface IGetValue + { + T Get(float time); + } + + [TrackColor(0.92f, 0.54f, 0.17f)] + [TrackBindingType(typeof(UIEffect), TrackBindingFlags.AllowCreateComponent)] + public abstract class UIEffectTrack : TrackAsset + where T : PlayableBehaviour, new() + { + protected abstract string fieldName { get; } + + public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) + { + var playable = ScriptPlayable.Create(graph, inputCount); + + foreach (var timelineClip in GetClips()) + { + if (timelineClip.asset is UIEffectClip clip) + { + clip.timelineClip = timelineClip; + } + } + + return playable; + } + + public override void GatherProperties(PlayableDirector director, IPropertyCollector driver) + { + var trackBinding = director.GetGenericBinding(this) as UIEffect; + if (!trackBinding) return; + + driver.AddFromName(trackBinding.gameObject, fieldName); + base.GatherProperties(director, driver); + } + } + + public abstract class UIEffectClip : PlayableAsset, ITimelineClipAsset + { + public TimelineClip timelineClip { get; set; } + public ClipCaps clipCaps => ClipCaps.Blending | ClipCaps.Extrapolation; + + private void OnValidate() + { + + } + } + + public abstract class UIEffectClip : UIEffectClip + where T : UIEffectBehaviour, new() + { + [NotKeyable] + [SerializeField] + public T m_Data = new T(); + + public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) + { + var playable = ScriptPlayable.Create(graph, m_Data); + var behaviour = playable.GetBehaviour(); + behaviour.clip = this; + return playable; + } + } + + [Serializable] + public abstract class UIEffectBehaviour : PlayableBehaviour + { + public bool m_Tween; + public AnimationCurve m_Curve = AnimationCurve.Linear(0, 0, 1, 1); + public UIEffectClip clip { get; set; } + } + + public abstract class UIEffectMixerBehaviour : PlayableBehaviour + where TBehavior : UIEffectBehaviour, IGetValue, new() + { + private T _defaultValue; + protected abstract T currentValue { get; set; } + protected UIEffect effect { get; private set; } + + public override void ProcessFrame(Playable playable, FrameData info, object playerData) + { + InitializeIfNeeded(playerData as UIEffect); + if (!effect) return; + + var inputCount = playable.GetInputCount(); + var value = default(T); + var totalWeight = GetTotalWeight(playable); + + for (var i = 0; i < inputCount; i++) + { + var weight = playable.GetInputWeight(i); + if (weight <= 0) continue; + + var playableInput = (ScriptPlayable)playable.GetInput(i); + var input = playableInput.GetBehaviour(); + var normalizedTime = (float)(playableInput.GetTime() / input.clip.timelineClip.duration); + + value = Add(value, input.Get(normalizedTime), weight / totalWeight); + totalWeight += weight; + } + + currentValue = Lerp(_defaultValue, value, totalWeight); + } + + public override void OnPlayableDestroy(Playable playable) + { + if (effect) + { + currentValue = _defaultValue; + } + } + + private static float GetTotalWeight(Playable playable) + { + var totalWeight = 0f; + var inputCount = playable.GetInputCount(); + for (var i = 0; i < inputCount; i++) + { + totalWeight += playable.GetInputWeight(i); + } + + return totalWeight; + } + + private void InitializeIfNeeded(UIEffect newEffect) + { + if (effect == newEffect) return; + + if (effect) + { + currentValue = _defaultValue; + } + + effect = newEffect; + _defaultValue = newEffect ? currentValue : default; + } + + protected abstract T Add(T current, T value, float weight); + + protected abstract T Lerp(T defaultValue, T value, float weight); + } +} + +#endif diff --git a/Packages/src/Runtime/Timeline/Base/UIEffectTimelineUtils.cs.meta b/Packages/src/Runtime/Timeline/Base/UIEffectTimelineUtils.cs.meta new file mode 100644 index 0000000..7aa74d0 --- /dev/null +++ b/Packages/src/Runtime/Timeline/Base/UIEffectTimelineUtils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a54d6ecf5bae485db4b0df376bebc35 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/ColorIntensityTrack.cs b/Packages/src/Runtime/Timeline/ColorIntensityTrack.cs new file mode 100644 index 0000000..db85474 --- /dev/null +++ b/Packages/src/Runtime/Timeline/ColorIntensityTrack.cs @@ -0,0 +1,25 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [FloatClipUsage(0f, 1f)] + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Color Intensity Track")] + public class ColorIntensityTrack : UIEffectTrack + { + protected override string fieldName => "m_ColorIntensity"; + } + + public class ColorIntensityMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.colorIntensity; + set => effect.colorIntensity = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/ColorIntensityTrack.cs.meta b/Packages/src/Runtime/Timeline/ColorIntensityTrack.cs.meta new file mode 100644 index 0000000..24be411 --- /dev/null +++ b/Packages/src/Runtime/Timeline/ColorIntensityTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 66d61d709d31c4220bc59365f78584ec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/ColorTrack.cs b/Packages/src/Runtime/Timeline/ColorTrack.cs new file mode 100644 index 0000000..e20dd33 --- /dev/null +++ b/Packages/src/Runtime/Timeline/ColorTrack.cs @@ -0,0 +1,26 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [ColorClipUsage(false)] + [TrackClipType(typeof(UIEffectColorClip))] + [DisplayName("UIEffect Tracks/Color Track")] + public class ColorTrack : UIEffectTrack + { + protected override string fieldName => "m_Color"; + } + + public class ColorMixer : UIEffectColorMixerBehaviour + { + protected override Color currentValue + { + get => effect.color; + set => effect.color = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/ColorTrack.cs.meta b/Packages/src/Runtime/Timeline/ColorTrack.cs.meta new file mode 100644 index 0000000..16e56a1 --- /dev/null +++ b/Packages/src/Runtime/Timeline/ColorTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: edfa6dc975b3446d8bc2cf6ca1fdd40f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/DetailColorTrack.cs b/Packages/src/Runtime/Timeline/DetailColorTrack.cs new file mode 100644 index 0000000..9d9b1ed --- /dev/null +++ b/Packages/src/Runtime/Timeline/DetailColorTrack.cs @@ -0,0 +1,26 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [ColorClipUsage(true)] + [TrackClipType(typeof(UIEffectColorClip))] + [DisplayName("UIEffect Tracks/Detail Color Track")] + public class DetailColorTrack : UIEffectTrack + { + protected override string fieldName => "m_DetailColor"; + } + + public class DetailColorMixer : UIEffectColorMixerBehaviour + { + protected override Color currentValue + { + get => effect.detailColor; + set => effect.detailColor = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/DetailColorTrack.cs.meta b/Packages/src/Runtime/Timeline/DetailColorTrack.cs.meta new file mode 100644 index 0000000..a4a4285 --- /dev/null +++ b/Packages/src/Runtime/Timeline/DetailColorTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 88051c9178d704e47a12db836b6343c0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/DetailIntensityTrack.cs b/Packages/src/Runtime/Timeline/DetailIntensityTrack.cs new file mode 100644 index 0000000..e1a4bb9 --- /dev/null +++ b/Packages/src/Runtime/Timeline/DetailIntensityTrack.cs @@ -0,0 +1,25 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [FloatClipUsage(0f, 1f)] + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Detail Intensity Track")] + public class DetailIntensityTrack : UIEffectTrack + { + protected override string fieldName => "m_DetailIntensity"; + } + + public class DetailIntensityMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.detailIntensity; + set => effect.detailIntensity = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/DetailIntensityTrack.cs.meta b/Packages/src/Runtime/Timeline/DetailIntensityTrack.cs.meta new file mode 100644 index 0000000..b58c0e1 --- /dev/null +++ b/Packages/src/Runtime/Timeline/DetailIntensityTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e901a5dfc37104d2182dcc49fe370305 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/EdgeColorTrack.cs b/Packages/src/Runtime/Timeline/EdgeColorTrack.cs new file mode 100644 index 0000000..1f4a26d --- /dev/null +++ b/Packages/src/Runtime/Timeline/EdgeColorTrack.cs @@ -0,0 +1,26 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [ColorClipUsage(true)] + [TrackClipType(typeof(UIEffectColorClip))] + [DisplayName("UIEffect Tracks/Detail Color Track")] + public class EdgeColorTrack : UIEffectTrack + { + protected override string fieldName => "m_EdgeColor"; + } + + public class EdgeColorMixer : UIEffectColorMixerBehaviour + { + protected override Color currentValue + { + get => effect.edgeColor; + set => effect.edgeColor = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/EdgeColorTrack.cs.meta b/Packages/src/Runtime/Timeline/EdgeColorTrack.cs.meta new file mode 100644 index 0000000..1fc4589 --- /dev/null +++ b/Packages/src/Runtime/Timeline/EdgeColorTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f78a05c2255e94329a1b7bd465ac8f8a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/EdgeShinyRateTrack.cs b/Packages/src/Runtime/Timeline/EdgeShinyRateTrack.cs new file mode 100644 index 0000000..3f8ffad --- /dev/null +++ b/Packages/src/Runtime/Timeline/EdgeShinyRateTrack.cs @@ -0,0 +1,25 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [FloatClipUsage(0f, 1f)] + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Edge Shiny Rate Track")] + public class EdgeShinyRateTrack : UIEffectTrack + { + protected override string fieldName => "m_EdgeShinyRate"; + } + + public class EdgeShinyRateMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.edgeShinyRate; + set => effect.edgeShinyRate = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/EdgeShinyRateTrack.cs.meta b/Packages/src/Runtime/Timeline/EdgeShinyRateTrack.cs.meta new file mode 100644 index 0000000..b199192 --- /dev/null +++ b/Packages/src/Runtime/Timeline/EdgeShinyRateTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 118c294bc3dfa4e7a96de50b410ad846 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/GradationIntensityTrack.cs b/Packages/src/Runtime/Timeline/GradationIntensityTrack.cs new file mode 100644 index 0000000..fd095c0 --- /dev/null +++ b/Packages/src/Runtime/Timeline/GradationIntensityTrack.cs @@ -0,0 +1,25 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [FloatClipUsage(0f, 1f)] + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Gradation Intensity Track")] + public class GradationIntensityTrack : UIEffectTrack + { + protected override string fieldName => "m_GradationIntensity"; + } + + public class GradationIntensityMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.gradationIntensity; + set => effect.gradationIntensity = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/GradationIntensityTrack.cs.meta b/Packages/src/Runtime/Timeline/GradationIntensityTrack.cs.meta new file mode 100644 index 0000000..1fa5041 --- /dev/null +++ b/Packages/src/Runtime/Timeline/GradationIntensityTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7b4c7c51d8c8c4d9ebfacb4ec8e7f73e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/GradationOffsetTrack.cs b/Packages/src/Runtime/Timeline/GradationOffsetTrack.cs new file mode 100644 index 0000000..fbd5e4f --- /dev/null +++ b/Packages/src/Runtime/Timeline/GradationOffsetTrack.cs @@ -0,0 +1,24 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Gradation Offset Track")] + public class GradationOffsetTrack : UIEffectTrack + { + protected override string fieldName => "m_GradationOffset"; + } + + public class GradationOffsetMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.gradationOffset; + set => effect.gradationOffset = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/GradationOffsetTrack.cs.meta b/Packages/src/Runtime/Timeline/GradationOffsetTrack.cs.meta new file mode 100644 index 0000000..f2ae4bb --- /dev/null +++ b/Packages/src/Runtime/Timeline/GradationOffsetTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: deb67c01293914e41a70a7570c3a539e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/GradationRotationTrack.cs b/Packages/src/Runtime/Timeline/GradationRotationTrack.cs new file mode 100644 index 0000000..f9db347 --- /dev/null +++ b/Packages/src/Runtime/Timeline/GradationRotationTrack.cs @@ -0,0 +1,24 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Gradation Rotation Track")] + public class GradationRotationTrack : UIEffectTrack + { + protected override string fieldName => "m_GradationRotation"; + } + + public class GradationRotationMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.gradationRotation; + set => effect.gradationRotation = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/GradationRotationTrack.cs.meta b/Packages/src/Runtime/Timeline/GradationRotationTrack.cs.meta new file mode 100644 index 0000000..5a58d2b --- /dev/null +++ b/Packages/src/Runtime/Timeline/GradationRotationTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eb2c49df5c5af40d189179c70f3f4e8f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/GradationScaleTrack.cs b/Packages/src/Runtime/Timeline/GradationScaleTrack.cs new file mode 100644 index 0000000..548036e --- /dev/null +++ b/Packages/src/Runtime/Timeline/GradationScaleTrack.cs @@ -0,0 +1,25 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [FloatClipUsage(0.01f, 10f)] + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Gradation Scale Track")] + public class GradationScaleTrack : UIEffectTrack + { + protected override string fieldName => "m_GradationScale"; + } + + public class GradationScaleMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.gradationScale; + set => effect.gradationScale = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/GradationScaleTrack.cs.meta b/Packages/src/Runtime/Timeline/GradationScaleTrack.cs.meta new file mode 100644 index 0000000..b626d74 --- /dev/null +++ b/Packages/src/Runtime/Timeline/GradationScaleTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0e9a4fc9655b64a399feaf134500daad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/SamplingIntensityTrack.cs b/Packages/src/Runtime/Timeline/SamplingIntensityTrack.cs new file mode 100644 index 0000000..bf14704 --- /dev/null +++ b/Packages/src/Runtime/Timeline/SamplingIntensityTrack.cs @@ -0,0 +1,25 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [FloatClipUsage(0f, 1f)] + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Sampling Intensity Track")] + public class SamplingIntensityTrack : UIEffectTrack + { + protected override string fieldName => "m_SamplingIntensity"; + } + + public class SamplingIntensityMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.samplingIntensity; + set => effect.samplingIntensity = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/SamplingIntensityTrack.cs.meta b/Packages/src/Runtime/Timeline/SamplingIntensityTrack.cs.meta new file mode 100644 index 0000000..e89d7ed --- /dev/null +++ b/Packages/src/Runtime/Timeline/SamplingIntensityTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae43eda84464f470db063babd75d86ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/ToneIntensityTrack.cs b/Packages/src/Runtime/Timeline/ToneIntensityTrack.cs new file mode 100644 index 0000000..ca24f0d --- /dev/null +++ b/Packages/src/Runtime/Timeline/ToneIntensityTrack.cs @@ -0,0 +1,25 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [FloatClipUsage(0f, 1f)] + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Tone Intensity Track")] + public class ToneIntensityTrack : UIEffectTrack + { + protected override string fieldName => "m_ToneIntensity"; + } + + public class ToneIntensityMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.toneIntensity; + set => effect.toneIntensity = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/ToneIntensityTrack.cs.meta b/Packages/src/Runtime/Timeline/ToneIntensityTrack.cs.meta new file mode 100644 index 0000000..ff9ec76 --- /dev/null +++ b/Packages/src/Runtime/Timeline/ToneIntensityTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c08d90226dd3d48c7b26e4148a627c30 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/TransitionColorTrack.cs b/Packages/src/Runtime/Timeline/TransitionColorTrack.cs new file mode 100644 index 0000000..895b4c7 --- /dev/null +++ b/Packages/src/Runtime/Timeline/TransitionColorTrack.cs @@ -0,0 +1,26 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [ColorClipUsage(true)] + [TrackClipType(typeof(UIEffectColorClip))] + [DisplayName("UIEffect Tracks/Transition Color Track")] + public class TransitionColorTrack : UIEffectTrack + { + protected override string fieldName => "m_TransitionColor"; + } + + public class TransitionColorMixer : UIEffectColorMixerBehaviour + { + protected override Color currentValue + { + get => effect.transitionColor; + set => effect.transitionColor = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/TransitionColorTrack.cs.meta b/Packages/src/Runtime/Timeline/TransitionColorTrack.cs.meta new file mode 100644 index 0000000..6457d9e --- /dev/null +++ b/Packages/src/Runtime/Timeline/TransitionColorTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6cbbddc14d5744997a755e56c474a436 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/Timeline/TransitionRateTrack.cs b/Packages/src/Runtime/Timeline/TransitionRateTrack.cs new file mode 100644 index 0000000..d8578c7 --- /dev/null +++ b/Packages/src/Runtime/Timeline/TransitionRateTrack.cs @@ -0,0 +1,25 @@ +#if TIMELINE_ENABLE +using System.ComponentModel; +using UnityEngine.Timeline; +using Coffee.UIEffects.Timeline; + +namespace Coffee.UIEffects +{ + [FloatClipUsage(0f, 1f)] + [TrackClipType(typeof(UIEffectFloatClip))] + [DisplayName("UIEffect Tracks/Transition Rate Track")] + public class TransitionRateTrack : UIEffectTrack + { + protected override string fieldName => "m_TransitionRate"; + } + + public class TransitionRateMixer : UIEffectFloatMixerBehaviour + { + protected override float currentValue + { + get => effect.transitionRate; + set => effect.transitionRate = value; + } + } +} +#endif diff --git a/Packages/src/Runtime/Timeline/TransitionRateTrack.cs.meta b/Packages/src/Runtime/Timeline/TransitionRateTrack.cs.meta new file mode 100644 index 0000000..9bac1ca --- /dev/null +++ b/Packages/src/Runtime/Timeline/TransitionRateTrack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 97f54e7d118464cd099026c08294dc29 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/src/Runtime/UIEffectBase.cs b/Packages/src/Runtime/UIEffectBase.cs index cd4b122..288c9e0 100644 --- a/Packages/src/Runtime/UIEffectBase.cs +++ b/Packages/src/Runtime/UIEffectBase.cs @@ -6,6 +6,9 @@ using UnityEngine.EventSystems; using UnityEngine.Profiling; using UnityEngine.UI; using UnityEditor; +#if TIMELINE_ENABLE +using UnityEngine.Timeline; +#endif [assembly: InternalsVisibleTo("UIEffect")] [assembly: InternalsVisibleTo("Coffee.UIEffect.Editor")] @@ -15,6 +18,9 @@ namespace Coffee.UIEffects [ExecuteAlways] [DisallowMultipleComponent] public abstract class UIEffectBase : UIBehaviour, IMeshModifier, IMaterialModifier, ICanvasRaycastFilter +#if TIMELINE_ENABLE + ,ITimeControl +#endif { private static readonly InternalObjectPool s_ContextPool = new InternalObjectPool(() => new UIEffectContext(), x => true, x => x.Reset()); @@ -254,5 +260,25 @@ namespace Coffee.UIEffects public abstract void SetRate(float rate, UIEffectTweener.CullingMask cullingMask); public abstract bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera); + + public void SetTime(double _) + { + } + + public void OnControlTimeStart() + { + if (this) + { + enabled = true; + } + } + + public void OnControlTimeStop() + { + if (this) + { + enabled = false; + } + } } }