UnityEditor and Build

When I Build my project, I get an error:
Assets\Player\PlAnim_Ladder.cs(7,34): error CS0234: The type or namespace name ‘EditorCurveBinding’ does not exist in the namespace ‘UnityEditor’ (are you missing an assembly reference?)
and
Assets\Player\PlAnim_Ladder.cs(4,30): error CS0234: The type or namespace name ‘AnimationUtility’ does not exist in the namespace ‘UnityEditor’ (are you missing an assembly reference?)

I’m using the AnimationUtility.GetEditorCurve() function to get animation curve parameters at run time.

How do I include the EditorCurveBinding and AnimationUtility classes in the Build or do a function replacement AnimationUtility.GetEditorCurve().

P.S.
I saw this thread

but couldn’t add UnityEditor.AnimationUtility and UnityEditor.EditorCurveBinding classes to Assembly Definitions.

I don’t know about equivalent, but both of those are part of the UnityEditor namespace, so they wont be part of the build as they are for the editor only.

What are you trying to do?

I have an animation of a character climbing ladder (Player_LadderBase).
I play it manually by changing the Motion Time (LdBaseTime) parameter :
pc.anim.SetFloat( idLdBaseTime, anBaseTime );
8401788--1109343--Untitled-1.jpg

The animation also animates the animPos variable of type Vector2.
8401788--1109346--Untitled-2.jpg

The character’s current Y coordinate depends on:

  1. height of attachment to the ladder
  2. how many cycles of the ascent / descent animation have passed
  3. what is the value of animPos.y on the first animation frame and on the last one
  4. what is the value of animPos.y on the current animation frame. For this I do AnimCurve.Evaluate( time ).

And in order to complete the 3rd and 4th points, I need to get the animation curve associated with animPos.y

You can, of course, hardcode the necessary values for animPos.y from the animation in the script, but this is not convenient, because if I change the animation, then the values will have to be changed manually (but this is possible).
But without an animation curve, it will be impossible to execute AnimCurve.Evaluate( time ) at all!

Now the animation of the movement on the stairs looks very good :

  1. at each moment of time, one foot is on the step, and does not hang in the air, as I saw in some other animations
  2. responds very quickly to user input - if you press the “up” button, the character moves up,
    if you press the “down” button, then the character moves down,
    If you release the buttons, it stops.

Now I can’t understand how this type of animation can be done without getting the animation curve?
I don’t know if I explained it clearly or not … How could I.

I looked closely at the AnimationClip class and noticed that it has a strange feature.
In PlayMode, you can add an animation curve to a clip ( SetCurve( relativePath, type, propertyName, curve) ) and remove all curves ( ClearCurves() ), but you can’t get a list of available curves!
Why this is done is not clear.

1 Like