Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Editor script to modify .anim files

Discussion in 'Editor & General Support' started by NightmareTFD, Oct 15, 2015.

  1. NightmareTFD

    NightmareTFD

    Joined:
    Feb 11, 2015
    Posts:
    39
    Hello,

    I am trying to write an Editor script to load and modify tangent values in animcation clips in .anim files however i can't seem to find the proper way to load the file.

    i have tried resources.load and resources.FindObjectsOfTypeAll however i haven't been success with either one of those.

    can someone please recommend a way to load .anim files in an editor script?

    Thank you kindly.
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    You first have to load your AnimationClip:
    Code (CSharp):
    1. AssetDatabase.LoadAssetAtPath<AnimationClip>(@"Assets/PathToAnim.anim")
    Then, you can access curve related properties using the AnimationUtility class.

    For example, the GetAllCurves() method is a good place to start - it returns all animation curves from the given animation clip.
     
  3. NightmareTFD

    NightmareTFD

    Joined:
    Feb 11, 2015
    Posts:
    39
    tyvm liortal.