Hi - We use AnimationCurve values for a lot of our gameplay tweak values. Whenever our designers click on an AnimationCurve to edit it the window which appears is clamped to the extents of the values in the curve. Is there a way to clamp to range to a different value ? Our designers are going bonkers having to constantly reset the zoom levels on the axes.
Hi - you can use the middle mouse to zoom in and out and F to re-frame the curves, but at the moment there is no range value that can be set, to the best of my knowlegde - have it put on feedback and try and get it voted on as much as possible
Hello, I found this and decided to show the full code
BoundedCurveAttribute.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoundedCurveAttribute : PropertyAttribute
{
public Rect bounds;
public int height;
public BoundedCurveAttribute(Rect bounds, int height = 1)
{
this.bounds = bounds;
this.height = height;
}
public BoundedCurveAttribute(int height = 1)
{
this.bounds = new Rect(0, 0, 1, 1);
this.height = height;
}
}
Editor/BoundedCurveDrawer.cs
using UnityEngine;
using UnityEditor;
[CustomPropertyDrawer(typeof(BoundedCurveAttribute))]
public class BoundedCurveDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
BoundedCurveAttribute boundedCurve = (BoundedCurveAttribute)attribute;
return EditorGUIUtility.singleLineHeight * boundedCurve.height;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
BoundedCurveAttribute boundedCurve = (BoundedCurveAttribute)attribute;
EditorGUI.BeginProperty(position, label, property);
property.animationCurveValue = EditorGUI.CurveField(
position,
label,
property.animationCurveValue,
Color.white,
boundedCurve.bounds
);
EditorGUI.EndProperty();
}
}
Thank you very much! Although, Iām having trouble using it. The code below gives the error: Attribute constructor parameter āboundsā has type āRectā, which is not a valid attribute parameter type.
This code works really well, although Iāve noticed an issue that I cannot, for the life of me, find out how to fix.
When opening the curve in a custom Inspector using āEditorGUILayout.PropertyField();ā full-screening another window, like the game window returns an error reading:
āInvalid editor window of type: UnityEditor.CurveEditorWindow, title: Curveā
āUnityEditor.EditorApplication:Internal_CallDelayFunctions ()ā
Iām not sure how the other windows effect the curve window that I already closed, but Iād imagine itās just how Unity manages editor window calls.
It sucks that there hasnāt been any solutions to this issue in all this time, how hard is it for Unity to set bounds for an animation curve? Super frustrating