glTFast
glTFast copied to clipboard
Import without animation
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?
use ImportSettings class and set animationMethod = ImportSettings.AnimationMethod.None;
Thank you!
use ImportSettings class and set animationMethod = ImportSettings.AnimationMethod.None;
I am getting animationMethod does not exist in this context.
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
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.
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.
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.
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
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);
Perfect, that’s The solution I was looking for. Thanks!