private void Initialize()
    {
        SketchfabPlugin.Initialize();         // Load header image
        setupAPI();

        _importer       = new GLTFEditorImporter(this.Repaint);
        _unzippedFiles  = new List <string>();
        _isInitialized  = true;
        _unzipDirectory = Application.temporaryCachePath + "/unzip";
        _header         = new GUIStyle(EditorStyles.boldLabel);

        _defaultImportDirectory = Application.dataPath + "/Import";

        this.minSize = minimumSize;
    }
Ejemplo n.º 2
0
 public SketchfabImporter(GLTFEditorImporter.ProgressCallback progressCallback, GLTFEditorImporter.RefreshWindow finishCallback)
 {
     _importer      = new GLTFEditorImporter(progressCallback, finishCallback);
     _unzippedFiles = new List <string>();
 }
Ejemplo n.º 3
0
        void OnGUI()
        {
            RefreshLogo();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(logo, GUILayout.Width(150), GUILayout.Height(150));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical();

            var foundGrids = GameObject.FindObjectsOfType <AlignmentScript>();

            if (foundGrids != null && foundGrids.Length > 0)
            {
                if (GUILayout.Button("Hide Alignment Grid"))
                {
                    for (int i = 0; i < foundGrids.Length; i++)
                    {
                        if (foundGrids[i] != null && foundGrids[i].gameObject != null)
                        {
                            GameObject.DestroyImmediate(foundGrids[i].gameObject);
                        }
                    }
                }
            }
            else
            {
                if (GUILayout.Button("Show Alignment Grid"))
                {
                    var grid = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/PlattarExporter/Plattar/Alignment/AlignmentPlane.prefab", typeof(GameObject));
                    var obj  = GameObject.Instantiate(grid);

                    obj.name = "Plattar Alignment Grid";
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Separator();

            if (Importer.importer == null)
            {
                EditorGUILayout.BeginVertical();
                EditorGUILayout.HelpBox("Select a GLTF file to import into the project", MessageType.Info);

                if (GUILayout.Button("Import GLTF"))
                {
                    string gltfPath = SelectGLTF();

                    if (gltfPath == null)
                    {
                        EditorUtility.DisplayDialog("Import Failed", "GLTF failed to import, file is invalid", "OK");
                    }
                    else
                    {
                        string name       = Path.GetFileNameWithoutExtension(gltfPath);
                        string importPath = Application.dataPath + "/GLTFImports/" + name;

                        Importer.importer = new GLTFEditorImporter((task, start, end) => {
                            float progress = start / end;
                            EditorUtility.DisplayProgressBar("Importing GLTF", "Importing " + name + " model, please wait...", progress);
                        }, () => {
                            // if this gets called, we are done!
                            Importer.importer = null;
                            EditorUtility.ClearProgressBar();
                        });

                        Importer.importer.setupForPath(gltfPath, importPath, name, true);
                        Importer.importer.Load();
                    }
                }

                EditorGUILayout.EndVertical();
            }
        }