GLTFUtility icon indicating copy to clipboard operation
GLTFUtility copied to clipboard

Can you provide an example scene using GLTF animation

Open SimonDarksideJ opened this issue 4 years ago • 4 comments

The Readme shows a nice example of animation in progress and the tool does process animations. However, in the code the Animations are only returned to the importer and don't appear to "go anywhere"

Is there an example project or scene using the importer demonstrating animations?

SimonDarksideJ avatar Feb 25 '20 22:02 SimonDarksideJ

@SimonDarksideJ Did you find out to work this out?

@Siccity Thanks for this awesome work man! I have been working with GLTF for quiet a while now. But first time with Unity. Was surprised that it is not supported natively. With a little bit of search found your repo.

Worked out the basic model loading at runtime stuff. But stuck with animations. Some example would help a lot.

Atekihcan avatar Aug 08 '20 20:08 Atekihcan

Never mind! Figured it out with some effort. Followed this article and it was pretty simple to make it work with legacy Animation API. Couldn't figure out how to make it work with latest Animator stuff yet, and what works is good enough for me right now.

Here is how you do it...

// Create new mesh.
AnimationClip[] animClips;
GameObject result = Importer.LoadFromFile(Application.dataPath + "/GLTF/BrainStem.glb", new ImportSettings(), out animClips);

// Setup animation, if there is any.
// Taking only the first clip for now. Should be pretty easy to extend it  to generalize
if (animClips.Length > 0)
{
    Animation anim = result.AddComponent<Animation>();
    animClips[0].legacy = true;
    anim.AddClip(animClips[0], animClips[0].name);
    anim.Play(animClips[0].name);
}

Atekihcan avatar Aug 09 '20 07:08 Atekihcan

Thanks @Atekihcan , hadn't gotten back to this as I hadn't heard anything back from @Siccity

SimonDarksideJ avatar Sep 01 '20 23:09 SimonDarksideJ

Potentially the code I've posted using the Playables API in issue #89 is the way to go. I'm also looking for a way of handling animation.

nicholasmaurer avatar Sep 14 '20 08:09 nicholasmaurer