Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

error CS0117: 'AnimationMode' does not contain a definition for 'GetCurveBindings'

Discussion in 'Scripting' started by carlosdaniel369, Nov 15, 2019.

Thread Status:
Not open for further replies.
  1. carlosdaniel369

    carlosdaniel369

    Joined:
    Nov 6, 2019
    Posts:
    5
    Library\PackageCache\com.unity.timeline@1.2.6\Runtime\Utilities\AnimatorBindingCache.cs(91,40): error CS0117: 'AnimationMode' does not contain a definition for 'GetCurveBindings'



    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Playables;
    5. using UnityEngine.Timeline;
    6. using UnityEditor;
    7.  
    8. namespace UnityEngine.Timeline
    9. {
    10.     /// <summary>
    11.     /// Animator to Editor Curve Binding cache. Used to prevent frequent calls to GetAnimatorBindings which can be costly
    12.     /// </summary>
    13.     class AnimatorBindingCache
    14.     {
    15.         public const string TRPlaceHolder = "TransformTR";
    16.         public const string ScalePlaceholder = "TransformScale";
    17.  
    18.         struct AnimatorEntry
    19.         {
    20.             public int animatorID;
    21.             public bool applyRootMotion;
    22.             public bool humanoid;
    23.         }
    24.  
    25.         class AnimatorEntryComparer : IEqualityComparer<AnimatorEntry>
    26.         {
    27.             public bool Equals(AnimatorEntry x, AnimatorEntry y) { return x.animatorID == y.animatorID && x.applyRootMotion == y.applyRootMotion && x.humanoid == y.humanoid; }
    28.             public int GetHashCode(AnimatorEntry obj) { return HashUtility.CombineHash(obj.animatorID, obj.applyRootMotion.GetHashCode(), obj.humanoid.GetHashCode()); }
    29.             public static readonly AnimatorEntryComparer Instance = new AnimatorEntryComparer();
    30.         }
    31.  
    32.         readonly Dictionary<AnimatorEntry, EditorCurveBinding[]> m_AnimatorCache = new Dictionary<AnimatorEntry, EditorCurveBinding[]>(AnimatorEntryComparer.Instance);
    33.         readonly Dictionary<AnimationClip, EditorCurveBinding[]> m_ClipCache = new Dictionary<AnimationClip, EditorCurveBinding[]>();
    34.  
    35.         private static readonly EditorCurveBinding[] kEmptyArray = new EditorCurveBinding[0];
    36.         private static readonly List<EditorCurveBinding> s_BindingScratchPad = new List<EditorCurveBinding>(1000);
    37.  
    38.         public AnimatorBindingCache()
    39.         {
    40.             AnimationUtility.onCurveWasModified += OnCurveWasModified;
    41.         }
    42.  
    43.         public EditorCurveBinding[] GetAnimatorBindings(GameObject gameObject)
    44.         {
    45.             if (gameObject == null)
    46.                 return kEmptyArray;
    47.  
    48.             Animator animator = gameObject.GetComponent<Animator>();
    49.             if (animator == null)
    50.                 return kEmptyArray;
    51.  
    52.             AnimatorEntry entry = new AnimatorEntry()
    53.             {
    54.                 animatorID = animator.GetInstanceID(),
    55.                 applyRootMotion = animator.applyRootMotion,
    56.                 humanoid = animator.isHuman
    57.             };
    58.  
    59.             EditorCurveBinding[] result = null;
    60.             if (m_AnimatorCache.TryGetValue(entry, out result))
    61.                 return result;
    62.  
    63.             s_BindingScratchPad.Clear();
    64.  
    65.             // Replacement for AnimationMode.GetAnimatorBinding - this is faster and allocates kB instead of MB
    66.             var transforms = animator.GetComponentsInChildren<Transform>();
    67.             foreach (var t in transforms)
    68.             {
    69.                 if (animator.IsBoneTransform(t))
    70.                     s_BindingScratchPad.Add(EditorCurveBinding.FloatCurve(AnimationUtility.CalculateTransformPath(t, animator.transform), typeof(Transform), TRPlaceHolder));
    71.             }
    72.  
    73.             var streamBindings = AnimationUtility.GetAnimationStreamBindings(animator.gameObject);
    74.             UpdateTransformBindings(streamBindings);
    75.             s_BindingScratchPad.AddRange(streamBindings);
    76.  
    77.             result = new EditorCurveBinding[s_BindingScratchPad.Count];
    78.             s_BindingScratchPad.CopyTo(result);
    79.             m_AnimatorCache[entry] = result;
    80.             return result;
    81.         }
    82.  
    83.         public EditorCurveBinding[] GetCurveBindings(AnimationClip clip)
    84.         {
    85.             if (clip == null)
    86.                 return kEmptyArray;
    87.  
    88.             EditorCurveBinding[] result;
    89.             if (!m_ClipCache.TryGetValue(clip, out result))
    90.             {
    91.                 result = AnimationMode.GetCurveBindings(clip);
    92.                 UpdateTransformBindings(result);
    93.                 m_ClipCache[clip] = result;
    94.             }
    95.  
    96.             return result;
    97.         }
    98.  
    99.         private static void UpdateTransformBindings(EditorCurveBinding[] bindings)
    100.         {
    101.             for (int i = 0; i < bindings.Length; i++)
    102.             {
    103.                 var binding = bindings[i];
    104.                 if (AnimationPreviewUtilities.IsRootMotion(binding))
    105.                 {
    106.                     binding.type = typeof(Transform);
    107.                     binding.propertyName = TRPlaceHolder;
    108.                 }
    109.                 else if (typeof(Transform).IsAssignableFrom(binding.type) && (binding.propertyName.StartsWith("m_LocalRotation.") || binding.propertyName.StartsWith("m_LocalPosition.")))
    110.                 {
    111.                     binding.propertyName = TRPlaceHolder;
    112.                 }
    113.                 else if (typeof(Transform).IsAssignableFrom(binding.type) && binding.propertyName.StartsWith("m_LocalScale."))
    114.                 {
    115.                     binding.propertyName = ScalePlaceholder;
    116.                 }
    117.                 bindings[i] = binding;
    118.             }
    119.         }
    120.  
    121.         public void Clear()
    122.         {
    123.             m_AnimatorCache.Clear();
    124.             m_ClipCache.Clear();
    125.         }
    126.  
    127.         void OnCurveWasModified(AnimationClip clip, EditorCurveBinding binding, AnimationUtility.CurveModifiedType modification)
    128.         {
    129.             m_ClipCache.Remove(clip);
    130.         }
    131.     }
    132. }
    133. #endif
    134.  
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    5,543
    Take a look at the documentation for Unity's GetCurveBindings()... I think you'll be surprised to find which object it actually lives on, an object you're already familiar with above. :)
     
  3. noclew

    noclew

    Joined:
    Jun 10, 2016
    Posts:
    12
    What kind of answer is this? GetCurveBinding belongs to AnimationUtility, and the op asks why it appears in a runtime script belonging to AnimationMode. Why don't you just give hime the answer?
     
  4. carlosdaniel369

    carlosdaniel369

    Joined:
    Nov 6, 2019
    Posts:
    5
    I give up unity because of this, people think you and a teacher in programming
     
    Boandlkrama and CoCoNutti like this.
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    5,543
    If you google something for someone, you teach them one thing.

    If you teach them how to google, they can teach themselves everything.

    In the specific case above, if you type the name of the identifier into google, the first hit is the actual answer to your question. Google is amazing. Embrace it.
     
    palex-nx and Skyfall106 like this.
  6. FailureFactory

    FailureFactory

    Joined:
    May 11, 2017
    Posts:
    1
    I came here using google, only to find the result was a guy telling me to use google. This answer was worse than nothing.
     
    tone44, hfts, ShadowAngel and 17 others like this.
  7. amk1855

    amk1855

    Joined:
    Mar 29, 2017
    Posts:
    2
    And that, my friend, is called "recursion"
     
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    5,543
    To understand recursion, you must first understand recursion.
     
    zombiegorilla and Ermiq like this.
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,859
    It's a perfect answer. From the proverb to give vs teach.
     
    zombiegorilla and Kurt-Dekker like this.
  10. WilliamNHarvey

    WilliamNHarvey

    Joined:
    Jul 23, 2018
    Posts:
    2
    can one of you just actually answer the question lol... this is the first result on google
     
  11. Rupert-NerdDayGames

    Rupert-NerdDayGames

    Joined:
    Sep 12, 2015
    Posts:
    5
    Open Package Manager and downgrade Timeline to the verified version.
     
    Honorsoft, Yasmine2019, hfts and 17 others like this.
  12. Ermiq

    Ermiq

    Joined:
    May 1, 2018
    Posts:
    11
    Just like many other similar errors, it may occur when the project contains some deprecated code from older versions of Unity. If you search for `GetCurveBindings` in Unity API, you'll find out that it now belongs to `AnimationUtility`: https://docs.unity3d.com/ScriptReference/AnimationUtility.GetCurveBindings.html

    Double click on the error in console, it should open the line of code that caused the error in your code editor. And try to change `AnimationMode` to `AnimationUtility`.
     
    gliealonso, Sab_Rango, koyoi and 2 others like this.
  13. Grootloops

    Grootloops

    Joined:
    Nov 16, 2016
    Posts:
    3
    Doing so, will result in new errors.

    This, also results in new errors.
     
  14. minism

    minism

    Joined:
    Feb 11, 2016
    Posts:
    2
    This thread is the most spectacular failure of help I've ever seen :p
     
    JFR, Manic_Raven, paullaster and 5 others like this.
  15. noclew

    noclew

    Joined:
    Jun 10, 2016
    Posts:
    12
    Try updating the problematic package, the timeline in this case. It solved my problem.
     
    JFR and unity_lrl89sm0TaCU4w like this.
  16. noclew

    noclew

    Joined:
    Jun 10, 2016
    Posts:
    12
    What makes you think that people want to be taught when they post a short question like this? Also, do you really think that checking the documentation will give OP meaningful knowledge to this problem?

    People have different levels of expertise, and an easy question for you may not be that easy for others. If you are tired of answering easy questions every time, you can just ignore them. You are not obliged to answer them, and there is no need to play newbies with another riddle. I am amazed that this reply was posted by a Unity person.
     
  17. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,859
    A much better approach is to lead the person into the answer so they know how to better address similar questions in the future and empower them to solve their own problems moving forward. Yes, it takes a few more steps on behalf of the user, I get that. I purposely answer questions just like this every single time. It's an investment into their ability to better solve problems they will run into moving forward. It saves their time and effort in the long run, and mine.
     
    zombiegorilla likes this.
  18. noclew

    noclew

    Joined:
    Jun 10, 2016
    Posts:
    12
    I do not object to your textbook opinion. When one needs something to eat, it is usually better to teach him how to catch a fish than to give him a fish. However, it is not always the case. Things get worse when the one only needs one fish for one-time use or when the teacher is just bad at teaching. In this thread, I personally see the second case here. All that the first responder said was to check the documentation of GetCurveBindings, which will lead to the fact that it belongs to AnimationUtility. However, knowing it does not help solve the problem, and I do not think that OP didn't check it. It is even stated in the error message. In my guess, OP updated his project with a new version of Unity, but he did not update the Timeline package. If that was the case, the solution is to update his Timeline package via Package Manager. However, this solution could be sometimes opaque to newbies, like me, because the Timeline package is included in the project by default. After all, the first responder's comment only adds another riddle on it.

    When we know something that someone does not, we tend to teach what we know. It is productive and healthy behavior. However, not everyone needs to be a teacher, especially when he/she is not good at teaching. Many times, I see people saying that they are teaching how to catch a fish. However, if it is not done properly, it is even worse than just handing over a fish.
     
    Last edited: Dec 15, 2019
  19. noclew

    noclew

    Joined:
    Jun 10, 2016
    Posts:
    12
    I am sorry, but you taught nothing. Embrace it.
     
    Last edited: Dec 14, 2019
    tone44 and gazou like this.
  20. ChrisSpringer

    ChrisSpringer

    Joined:
    Jun 20, 2018
    Posts:
    1
    As a last resort, you can choose to "Reset packages to defaults" from the main Unity Help menu. This worked for me. However, be aware that this action resets all changes you made to the packages in your Project.
     
    vitaliy-ostrovsky likes this.
  21. dgaxel

    dgaxel

    Joined:
    Mar 25, 2016
    Posts:
    1
    You are literally the Polar Express meme
     
  22. Bola

    Bola

    Joined:
    Dec 9, 2016
    Posts:
    1
    Window --> Package Manager downgrade "Unity Timeline package to v. 1.1.0 - resolved
     
  23. pav-orestis

    pav-orestis

    Joined:
    Jun 1, 2015
    Posts:
    3
    tldr: Some artifacts remained from the previous installation that were still pointing to AnimationMode.GetCurveBindings. Deleting these files (in Library/PackageCache) worked for me.

    Some people just don't want to help - reading the posts above (Which some come from reputable people - even Unity support employees) it seems that they didn't even bother actually reading your question. It's evident by one person who assumed the code you pasted is your own code, and another person who insists that simply throwing a child in a lake is a productive swimming lesson.

    In any case, to actually provide some insights:

    In my case I created and built my project using unity version 2019.3.0b4 and everything were working fine, until I upgraded to version 2019.3.0a5 at which point I was getting the same error as you are getting because in the new unity runtime framework the method AnimationMode.GetCurveBindings was removed and was possibly replaced by AnimationUtility.GetCurveBindings.

    From the error it seems that some artifacts remained from the previous installation that were still pointing to AnimationMode.GetCurveBindings. I deleted these files (in Library/PackageCache) and it worked for me.

    Another solution would be to downgrade the package 'Unity Timeline' from version 1.2.0 to 1.1.0 but this might cause other issues if the older version of this package is incompatible with the rest newer packages.

    Hope this helps others who may end up here.
     
    gliealonso, JFR, Manic_Raven and 7 others like this.
  24. NitromeSteed

    NitromeSteed

    Joined:
    Jul 28, 2017
    Posts:
    17
    I have found this thread because Unity refused to compile an empty project. The error is caused by Unity's own code.

    The error is caused by incompetence on the behalf of the people who make Unity.

    Having been led to the answer I sought, I am neither pleased nor enlightened. I did not gain any appreciation for anything, only further distrust of the tools I use and immense frustration. I hope the next error that Unity produces does not lead me to another thread like this.

    And yes, rolling back the code for the Timeline package to 1.1.0 helped. Uninstalling Unity's code helped.
     
    Manic_Raven and Jeremy-Borton like this.
  25. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,859
    You should always Google first for a solution, that was my only point. I often forget to search first myself! Yes, this was a frustrating issue. I'm not familiar with the issue myself and gave it a try and saw the same error. So I Googled it, and the first link that I found suggested that the API had changed, so I tried a different version as my first test, and it worked for me. I will always attempt to educate the user on the forum rather than give a blind answer. It works 90% of the time, the other 10% end up like this one, and not so good. But it's a good bet.
     
  26. Smileypop

    Smileypop

    Joined:
    Jan 15, 2015
    Posts:
    3
    Jeff, nobody cares how you Googled the problem to find the answer. If you really are a support specialist, you are terrible at your job. You need to be properly retrained or fired. It's that simple. If on the other hand you were not hired to comment on these forums, then please refrain from doing so.

    There are other users who have provided clear, helpful answers. Thank you to them for doing it for free. Your salary is a waste of Unity resources.
     
  27. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,859
    Sorry, no :) It's much better to teach users how to find the answers themselves.
     
  28. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,859
  29. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    6,981
    Some of us here prefer to show people how to find the answer. Since just giving the answer turns us into an unpaid man-powered search engine for the benefit of the user to lazy too research themselves.

    If you don't know where the fridge is, why should I get you a cup of juice every time you ask for it? Why not show you where the fridge is? Are you a 2 year old that can't get juice for yourself?

    I will agree sometimes the like of Kurt-Dekker, Jeff, myself, and many others may come off a little passive-aggressive when we do it. But that's just because we spend a good deal of our day answering questions over and over and over. And we sort of just want to be like "hey guys, there's this thing called documentation right over here. How do you think we know all of these answers?"

    Because a big thing is, as a programmer, the namespace/location of a known method changing between versions is a thing you'll run into a lot no matter what development you're doing. This is something you should learn very early on and documentation is how you can identify that it has moved, and where it has moved to.
     
    Last edited: Jan 15, 2020
    Ermiq and JeffDUnity3D like this.
  30. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,353
    You completely failed to do so. I searched around regarding this same problem and found this worthless thread. You should be ashamed to call yourself "Developer Support" and your behavior here is an embarrassment to Unity. I love Unity and I hope nobody considering the engine comes across posts like the ones you've made here and thinks that this is how Unity supports its users. If that's the reputation Unity gets, it will soon fail, and I don't want to see that happen.

    The code the OP posted was not their own, and knowing what class the method was moved to does not do much to help resolve the problem, given that the code raising the error is Unity's, not theirs. It's not like they're going to go and refactor the original package themselves.

    ***SOLUTION***
    It appears the problem can arise when a project has been imported with a newer version of Unity (such as 2019.3), which apparently automatically updates package versions to newer ones compatible with the newer Unity version. Then when the project is reverted back to, say 2019.2, and version control doesn't track the installed packages, the newer packages remain installed. In other words, 2019.3 apparently automatically upgrades some of the packages to versions that are incompatible with the prior version, and when reverting the project, the packages don't get reverted to match.

    The solution appears to be to look at which packages are causing the errors and go into the Package Manager and remove each of them. You may then also have to reinstall them again, but this time Unity should make sure it only installs the latest version that is compatible with that version of Unity.

    ^^^ THERE! That's how you help.

    It took several steps of deduction to arrive at this solution, and the "help" you provided barely even touches on the first step in that chain. And yes, you might think everyone should be capable of going through all those same steps for themselves. But in case you are unaware of the purpose of "support", it is not to be a wise sage leading padawans into enlightenment. We are busy people with tons of work piled on our shoulders, and sometimes we run into weird edge cases like this one that we don't have time or bandwidth to fully diagnose ourselves, and that's why it's nice if someone else knows the quirky thing that is happening in cases like this one, and can just explain what's happened and what steps one should take to resolve it. In short, as support, your job is to help relieve our workload, not increase it. Hell, if I wanted to be lead into how to do everything myself, I wouldn't be using a pre-made engine in the first place! I'd write my own! The entire reason people like me jumped on board with Unity (as I did back in 2007) is so we could focus on creating content as much as possible and reduce the time we spend troubleshooting.
     
    Last edited: Jan 28, 2020
  31. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    158
    Thanks to everyone who doesn't actually work at Unity for the help!
     
  32. dbond89

    dbond89

    Joined:
    Aug 22, 2018
    Posts:
    2
    This is the first result on Google when I search... If you are trying to create a "teaching" moment, you could have simply said "if you look at the error line, you'll see its an issue with Timeline in the Package Library", and not "google it". Some of us who are still trying to familiarise ourselves with Unity wouldn't realise that at first glance.

    Thanks to others who have posted complete answers and helped out.
     
    JFR, Manic_Raven, vicman4 and 4 others like this.
  33. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,041
    Closing. For future note, take better care to post useful and competent threads. The OP is terrible and lazy. They literally posted an error and some code. ("Fix my stuff!!!111" is not a good way to get help) There is no question there. They didn't post what they had tried and what they are expecting. Normally that thread would have just been deleted.

    Learn to Google.
    Learn to read and and understand docs.
    Go through the learn section.
    And most important, learn to ask proper questions.

    Closing. The answer is in the first reply. The rest is useless bickering.
     
    Ermiq likes this.
Thread Status:
Not open for further replies.
unityunity