Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Bug AnimationClipSettings.stopTime not taking into effect unless Unity is restarted.

Discussion in 'Animation' started by mrkotfw, Sep 6, 2020.

  1. mrkotfw

    mrkotfw

    Joined:
    Oct 27, 2012
    Posts:
    10
    Version: 2018.4.26f1
    Code (csharp):
    1. var animationClipSettings = AnimationUtility.GetAnimationClipSettings(animationClip);
    2. animationClipSettings.startTime = 0.0f;
    3. animationClipSettings.stopTime = _stopFrameCount / animationClip.frameRate;
    4. AnimationUtility.SetAnimationClipSettings(animationClip, animationClipSettings);
    5. EditorUtility.SetDirty(animationClip);
    6. AssetDatabase.CreateAsset(animationClip, path);
    7. AssetDatabase.SaveAssets();
    8. AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
    If I open the animation file in my editor, I can see
    m_stopTime
    set correctly. However, in the inspector window, it's still the old value. If I restart Unity, it works.

    If the value is say, 0.0333335, I just change it to 0.033334 in my text editor (so Unity sees the change), and I can see the changes.
     
    Last edited: Sep 6, 2020
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,523
    I've seen the something similar when marking animations as looping/not, except that it actually shows the correct value in the Inspector but then ignores the change in Play Mode until Unity is restarted.

    Did you report a bug?
     
    mrkotfw likes this.
  3. mrkotfw

    mrkotfw

    Joined:
    Oct 27, 2012
    Posts:
    10
    I've seen those posts, I believe. I'll do that now.
     
unityunity