- Home /
Custom Inspector - Accessing AnimationCurve
I'm trying to add some functionality to the inspector when using AnimationCurves. I'm having trouble accessing the AnimationCurve itself so I can eventually modify it. I get the error that Unity.Object cannot be converted to AnimationCurve. I don't get this error if my editor script targets one of my custom scripts, only if I target a unity class.
If I add buttons to this script, it applies them to every public AnimationCurve variable in my project, which is exactly what I want, but since I can't actually access the animationcurve to make changes to it, its not doing me any good.
[CustomEditor(typeof(AnimationCurve))]
public class ExtendedCurves : Editor
{
private AnimationCurve thisCurve;
public void OnEnable()
{
thisCurve = (AnimationCurve)target;
}
}
I am also interested in gaining access to AnimationCurves that I created .. I do not see them in the inspector ? I tried also opening the Animation window... but nothing :(
Answer by andrew-lukasik · Mar 10, 2017 at 10:39 AM
CustomEditors are usually written for Monobehaviour scripts and won't work with AnimationCurve type since it inherits only from System.Object (from what I can tell).
I suspect that the thing you're really looking for is an attribute called CustomPropertyDrawer. If that is the case then make this ExtendedCurves class a typical wrapper inheriting from nothing and write CustomPropertyDrawer for it. ExtendedCurves in this scenario can contain and extend AnimationCurve's functionality easily without conflicts.
Your answer
Follow this Question
Related Questions
Inspector editable animation curves (without animation curve class please) 2 Answers
Unity inspector scripting - scriptable objects - card game 0 Answers
How to properly handle Undo events in custom inspector? 0 Answers
How to assign a color shown in the "Color" window to a color field in the inspector? 6 Answers
Skybox - Render Settings vs on a Camera 0 Answers