Skip to content

Commit

Permalink
Another Checkpoint
Browse files Browse the repository at this point in the history
Start PowerEnum feature; fixes to generic animation; new issues with timeline applying event though not on clip; bunch of misc stuff
  • Loading branch information
Luca3317 committed Oct 25, 2024
1 parent a2ab7be commit f1192c4
Show file tree
Hide file tree
Showing 32 changed files with 2,597 additions and 1,569 deletions.
56 changes: 56 additions & 0 deletions Package/Editor/FancyAnimationCurveDrawer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using AnimationUtility = TMPEffects.TMPAnimations.AnimationUtility;

[CustomPropertyDrawer(typeof(AnimationUtility.FancyAnimationCurve))]
public class FancyAnimationCurveDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);

var rect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);

var width = EditorStyles.label.CalcSize(label);
var ctrlRect = EditorGUI.PrefixLabel(rect, GUIUtility.GetControlID(FocusType.Passive, rect), label);
var foldoutRect = new Rect(rect.x + width.x + 15, rect.y, 20, EditorGUIUtility.singleLineHeight);

var curveProp = property.FindPropertyRelative("curve");

curveProp.isExpanded = EditorGUI.Foldout(foldoutRect, curveProp.isExpanded, new GUIContent(""));

// TODO Strange ass workaround for offset created by EditorGUI.PrefixLabel
EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
EditorGUI.PropertyField(ctrlRect, curveProp, new GUIContent(""));
EditorGUI.indentLevel++;
EditorGUI.indentLevel++;

if (curveProp.isExpanded)
{
EditorGUI.indentLevel++;
rect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, property.FindPropertyRelative("offsetType"));
rect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, property.FindPropertyRelative("wrapMode"));
rect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, property.FindPropertyRelative("uniformity"));
EditorGUI.indentLevel--;
}

EditorGUI.EndProperty();
}

public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
var curveProp = property.FindPropertyRelative("curve");
if (curveProp.isExpanded)
{
return EditorGUIUtility.singleLineHeight * 4;
}

return EditorGUIUtility.singleLineHeight;
}
}
11 changes: 11 additions & 0 deletions Package/Editor/FancyAnimationCurveDrawer.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions Package/Editor/GenericAnimation/AnimationStepDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,15 @@ protected float GetCommonHeight(SerializedProperty property)
{
float height = EditorGUIUtility.singleLineHeight * 3; // Blending + in out headers

if (entryCurve.isExpanded) height += EditorGUIUtility.singleLineHeight * 2;
if (exitCurve.isExpanded) height += EditorGUIUtility.singleLineHeight * 2;
if (entryCurve.isExpanded)
{
height += EditorGUIUtility.singleLineHeight + EditorGUI.GetPropertyHeight(entryCurve);
}

if (exitCurve.isExpanded)
{
height += EditorGUIUtility.singleLineHeight + EditorGUI.GetPropertyHeight(exitCurve);
}

height += EditorGUIUtility.singleLineHeight * 3; // Space + waves

Expand Down Expand Up @@ -87,7 +94,7 @@ protected void DrawCommon(Rect rect, SerializedProperty property, GUIContent lab
if (entryCurve.isExpanded)
{
EditorGUI.indentLevel++;
var bgRect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight * 2);
var bgRect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight +EditorGUI.GetPropertyHeight(entryCurve));
EditorGUI.DrawRect(bgRect, backgroundColor);

EditorGUI.BeginChangeCheck();
Expand All @@ -100,7 +107,7 @@ protected void DrawCommon(Rect rect, SerializedProperty property, GUIContent lab

rect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, entryCurve);
rect.y += EditorGUIUtility.singleLineHeight;
rect.y += EditorGUI.GetPropertyHeight(entryCurve);
EditorGUI.indentLevel--;
}

Expand All @@ -110,7 +117,7 @@ protected void DrawCommon(Rect rect, SerializedProperty property, GUIContent lab
if (exitCurve.isExpanded)
{
EditorGUI.indentLevel++;
var bgRect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight * 2);
var bgRect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight + EditorGUI.GetPropertyHeight(exitCurve));
EditorGUI.DrawRect(bgRect, backgroundColor);

EditorGUI.BeginChangeCheck();
Expand All @@ -123,7 +130,7 @@ protected void DrawCommon(Rect rect, SerializedProperty property, GUIContent lab

rect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, exitCurve);
rect.y += EditorGUIUtility.singleLineHeight;
rect.y += EditorGUI.GetPropertyHeight(exitCurve);
EditorGUI.indentLevel--;
}

Expand Down
Loading

0 comments on commit f1192c4

Please sign in to comment.