glTFast icon indicating copy to clipboard operation
glTFast copied to clipboard

Import without animation

Open mchauth opened this issue 1 year ago • 2 comments

Hi this is a dumb question. I am trying to use gltfasset.cs to bring in my models without the animation clips. The other day I was messing with the package settings in the editor but I had to reinstall it and now I don't see those settings (which had filters of what to import, meshes, light, camera, etc.)

Is there a simple way to do this?

mchauth avatar Aug 11 '22 02:08 mchauth

use ImportSettings class and set animationMethod = ImportSettings.AnimationMethod.None;

andypoly avatar Aug 12 '22 13:08 andypoly

Thank you!

mchauth avatar Aug 12 '22 17:08 mchauth

use ImportSettings class and set animationMethod = ImportSettings.AnimationMethod.None;

I am getting animationMethod does not exist in this context. Screen Shot 2022-08-13 at 9 30 55 PM

mchauth avatar Aug 14 '22 02:08 mchauth

Currently you cannot disable animation import from the GltfAsset's inspector.

However, you can load it manually from code like so:

async void Start() {
        var gltf = new GltfImport();

        // Create a settings object and configure it accordingly
        var settings = new ImportSettings {
            animationMethod = ImportSettings.AnimationMethod.None
        };
    
        // Load the glTF and pass along the settings
        var success = await gltf.Load(uri, settings);

        if (success) {
            gltf.InstantiateMainScene(new GameObject("glTF").transform);
        }
        else {
            Debug.LogError("Loading glTF failed!");
        }
    }

hth

atteneder avatar Aug 24 '22 16:08 atteneder

Currently you cannot disable animation import from the GltfAsset's inspector.

I'm considering exposing those in the inspector though. Watch out for the next release.

atteneder avatar Aug 24 '22 17:08 atteneder

Hey man I hate to bother you, do you know how I can instantiate the model to be the child of the gameObject calling the script? instead of going to the top of the hierarchy.

mchauth avatar Nov 07 '22 01:11 mchauth

Hey man I hate to bother you, do you know how I can instantiate the model to be the child of the gameObject calling the script? instead of going to the top of the hierarchy.

@mchauth Are you using the GltfAsset component? The upcoming 5.x version will have a setting for creating a root object representing the scene (options never, always, when single root node). If you cannot wait, custom instantiation code allows you to create a GameObject of your own.

atteneder avatar Nov 07 '22 10:11 atteneder

I was using gltfasset which worked for going to the root, but I couldn’t pass animation settings through.

I was able to disable animation via the method you provided but can’t figure out how to catch and SetParent the InstantiateMainScene(new GameObject(“gLTF”).transform); without creating a script just for assigning children. Just hoping there’s a simpler way from the import script haha

mchauth avatar Nov 07 '22 13:11 mchauth

I was using gltfasset which worked for going to the root, but I couldn’t pass animation settings through. I was able to disable animation via the method you provided but can’t figure out how to catch and SetParent the InstantiateMainScene(new GameObject(“gLTF”).transform); without creating a script just for assigning children. Just hoping there’s a simpler way from the import script haha

Have you tried passing the current transform instead of creating a new GameObject?:

InstantiateMainScene(transform);

atteneder avatar Nov 07 '22 16:11 atteneder

Perfect, that’s The solution I was looking for. Thanks!

mchauth avatar Nov 07 '22 18:11 mchauth