-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
load glb files in editor time #797
Comments
Can you add a bit more info on what you want to do? If you put the GLB files into your project they will be imported by UnityGTLF through Unity's regular import pipeline. No code needed. |
As a minimal example :
|
I want to fill out the LoadGlbFile function to be able to spawn the glb asset as a gameObject |
It seems that what you're actually trying to do is add components and so on to the objects already imported via the editor importer? The recommended way would be using an import plugin (from UnityGLTF), which allows you to modify what is imported by the ScriptedImporter directly. If your file is really in Assets and you want to create a prefab variant from it, then it would be like this: private void LoadGlbFile(string assetPath)
{
GameObject newObject = PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(path)) as GameObject;
newObject.AddComponent<SphereCollider>(); // example for modification
newObject.name = selected.name + " Variant";
PrefabUtility.SaveAsPrefabAsset(newObject, "Assets/" + newObject.name + "_variant" + ".prefab");
DestroyImmediate(newObject);
} |
Hi,
I have glb files in local folders within the Asset directory that I would like to load during editor time by using a custom button and text field.
Is that possible through the importer ?
The text was updated successfully, but these errors were encountered: