Пример #1
0
        public static ImporterContext Load(string path)
        {
            var context = new ImporterContext();

            context.Load(path);
            context.ShowMeshes();
            context.EnableUpdateWhenOffscreen();
            return(context);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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));
            }
        }
Пример #4
0
 public static void Load(ImporterContext context)
 {
     context.Load();
     context.ShowMeshes();
     context.EnableUpdateWhenOffscreen();
 }