public static ImporterContext Load(string path) { var context = new ImporterContext(); context.Load(path); context.ShowMeshes(); context.EnableUpdateWhenOffscreen(); return(context); }
public static void LoadVrmAsync(string path, Byte[] bytes, Action <GameObject> onLoaded, Action <Exception> onError = null, bool show = true) { var context = new ImporterContext(); context.Parse(path, bytes); context.LoadAsync(() => { if (show) { context.ShowMeshes(); } onLoaded(context.Root); }, onError); }
public static void ImportMenu() { var path = EditorUtility.OpenFilePanel("open gltf", "", "gltf,glb,zip"); if (string.IsNullOrEmpty(path)) { return; } if (Application.isPlaying) { // // load into scene // var context = new ImporterContext(); context.Load(path); context.ShowMeshes(); Selection.activeGameObject = context.Root; } else { // // save as asset // if (path.StartsWithUnityAssetPath()) { Debug.LogWarningFormat("disallow import from folder under the Assets"); return; } var assetPath = EditorUtility.SaveFilePanel("save prefab", "Assets", Path.GetFileNameWithoutExtension(path), "prefab"); if (string.IsNullOrEmpty(path)) { return; } // import as asset gltfAssetPostprocessor.ImportAsset(path, Path.GetExtension(path).ToLower(), UnityPath.FromFullpath(assetPath)); } }
public static void Load(ImporterContext context) { context.Load(); context.ShowMeshes(); context.EnableUpdateWhenOffscreen(); }