Beispiel #1
0
        void ImportCompleteUniverses()
        {
            if (!CheckDataFolder(dataFilePath))
            {
                Debug.LogError("Wrong path (should be [GameDirectory]/data )");
                return;
            }
            var job = new PackageLoadJob(GetCompleteUniversesFilePath(), "Packages", new TransientImportLocator());

            try
            {
                EditorUtility.DisplayProgressBar("Loading Complete_UniverseSBU", string.Empty, 33);
                job.LoadObjects(true);
                if (pauseForDebugger)
                {
                    EditorUtility.DisplayDialog("", "Attach debugger now", "Ok");
                }
                EditorUtility.DisplayProgressBar("Loading Complete_UniverseSBU", string.Empty, 66);
                job.DeserializeObjectContent();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
                job.Finish();
            }
        }
Beispiel #2
0
        void LoadAllPackages(List <string> paths, bool isGameplayPackage, string targetProjectFolder, IResourceLocator resourceLocator)
        {
            PackageObject.ResetIDs();
            var jobs = new PackageLoadJob[paths.Count];

            for (var i = 0; i < paths.Count; i++)
            {
                jobs[i] = new PackageLoadJob(paths[i], targetProjectFolder, resourceLocator);
            }
            try
            {
                for (var i = 0; i < jobs.Length; i++)
                {
                    if (EditorUtility.DisplayCancelableProgressBar("Creating Structures", string.Format("{0}/{1} - {2}", i, jobs.Length, jobs[i].PackageName),
                                                                   Mathf.Clamp01((float)i / jobs.Length) * 0.5f))
                    {
                        if (EditorUtility.DisplayDialog("Cancel?", "temporary objects will not be cleaned up", "Yes", "No"))
                        {
                            throw new Exception("aborted");
                        }
                    }
                    jobs[i].LoadObjects(isGameplayPackage);
                }
                if (pauseForDebugger)
                {
                    EditorUtility.DisplayDialog("", "Attach debugger now", "Ok");
                }
                for (var i = 0; i < jobs.Length; i++)
                {
                    if (EditorUtility.DisplayCancelableProgressBar("Importing Package Data", string.Format("{0}/{1} - {2}", i, jobs.Length, jobs[i].PackageName),
                                                                   0.5f + Mathf.Clamp01((float)i / jobs.Length) * 0.5f))
                    {
                        if (EditorUtility.DisplayDialog("Cancel?", "temporary objects will not be cleaned up", "Yes", "No"))
                        {
                            throw new Exception("aborted");
                        }
                    }
                    jobs[i].DeserializeObjectContent();
                }
                if (!isGameplayPackage)
                {
                    for (var i = 0; i < jobs.Length; i++)
                    {
                        EditorUtility.DisplayProgressBar("Creating Map files", string.Format("{0}/{1} - {2}", i, jobs.Length, jobs[i].PackageName), Mathf.Clamp01((float)i / jobs.Length));
                        var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
                        EditorSceneManager.MoveGameObjectToScene(jobs[i].Package.gameObject, scene);
                        while (jobs[i].Package.transform.childCount > 0)
                        {
                            jobs[i].Package.transform.GetChild(0).parent = null;
                        }
                        GameObject.DestroyImmediate(jobs[i].Package.gameObject, false);
                        EditorSceneManager.SaveScene(scene, string.Format("Assets/{0}/{1}.unity", targetProjectFolder, jobs[i].PackageName));
                        EditorSceneManager.CloseScene(scene, true);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
            finally
            {
                for (var i = 0; i < jobs.Length; i++)
                {
                    jobs[i].Finish();
                }
                EditorUtility.ClearProgressBar();
                AssetDatabase.SaveAssets();
            }
        }