Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback [FEATURE REQUEST] Edit Loop setting at runtime

Discussion in 'Editor & General Support' started by jhocking, Nov 18, 2020.

  1. jhocking

    jhocking

    Joined:
    Nov 21, 2009
    Posts:
    813
    This is half a request to change how that animation setting works, and half wondering why that setting works the way it does. Specifically, I am talking about how the "Loop Time" checkbox can only be toggled in the editor.

    While working with GLTF files lately, I figured out the code to adjust that setting:
    https://forum.unity.com/threads/gltfutility-a-simple-gltf-plugin.654319/page-4#post-6506247

    As noted there, this code relies on the UnityEditor namespace and thus only works in the editor. But the thing is, it works even while the game is playing, not only beforehand as some sort of preparation step. That is, in the code that runs when I hit Play, I could load the model from StreamingAssets (ie. load it at runtime), toggle loopTime with that code, and then play the looping animation using the Playables API. That's still in the editor, but also while the game is playing.

    Is there a reason Unity can't enable this functionality in a built game? I never thought about this limitation before, because I never did anything before where it mattered, but as I mess with loading GLTF files at runtime I'm realizing there's no way to loop animations loaded that way, and that seems silly.