Search Unity

How to add animation event to imported animation clip?

Discussion in 'Animation' started by TalentedYao, Apr 29, 2019.

  1. TalentedYao

    TalentedYao

    Joined:
    May 16, 2017
    Posts:
    2
    Hello,

    I am trying to add animation events to imported animation clip in my custom editor.
    I found some solution like this
    https://forum.unity.com/threads/animationutility-setanimationevents-not-working.243810/
    (#3)
    Here is a part of that function
    Code (CSharp):
    1.  
    2. ModelImporter modelImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(targetAnimClip)) as ModelImporter;
    3.         if (modelImporter == null)
    4.             return;
    5.  
    6.         SerializedObject serializedObject = new SerializedObject(modelImporter);
    7.         SerializedProperty clipAnimations = serializedObject.FindProperty("m_ClipAnimations");
    8.  
    My problem is ,when i use "FindProperty("m_ClipAnimations")" its return nothing.
    Has this property changed name in new version?Or something else i had not noticed?
    I'm using unity 2018.3.11f
    Please help me !Thanks!!!
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Just use serializedObject.GetIterator to go through all the properties and log their names.
     
  3. TalentedYao

    TalentedYao

    Joined:
    May 16, 2017
    Posts:
    2
    Thanks!!!!
    You taught me a new knowledge!

    The property hadn't changed name.
    I made a silly spell mistake.It's settled now.

    Thanks again.