public static Coroutine UnloadAll()
    {
        var loadedKinds = new List <SceneKind>();

        SceneWrapper.GetLoaded(loadedKinds);
        loadedKinds.Remove(SceneData.immortalSceneKind);
        return(UnloadScenes(loadedKinds));
    }
        public static async Task ProjectService_CreateProjectTest()
        {
            var assemblyService = Substitute.For <IAssemblyService>();
            var dialogService   = Substitute.For <IDialogService>();
            var loggingService  = Substitute.For <ILoggingService>();
            var sceneService    = Substitute.For <ISceneService>();
            var projectService  = new ProjectService(new Serializer(), assemblyService, dialogService, loggingService, sceneService);

            var projectDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestProject");

            if (Directory.Exists(projectDirectory))
            {
                Directory.Delete(projectDirectory, true);
            }

            dialogService.ShowCreateProjectDialog(out Arg.Any <Project>(), Arg.Any <string>()).Returns(x => {
                x[0] = new Project()
                {
                    Name          = "TestProject",
                    PathToProject = Path.Combine(projectDirectory, $"TestProject{FileHelper.ProjectExtension}")
                };

                return(true);
            });

            dialogService.ShowSaveDiscardCancelDialog().Returns(SaveDiscardCancelResult.Cancel);

            var scene = new Scene()
            {
                Name = Guid.NewGuid().ToString()
            };

            var sceneWrapper = new SceneWrapper(scene);

            dialogService.ShowYesNoMessageBox(Arg.Any <string>(), Arg.Any <string>()).Returns(true);
            sceneService.CreateScene().Returns(sceneWrapper);
            sceneService.SaveCurrentScene(Arg.Any <Project>()).Returns(true);
            sceneService.LoadScene(Arg.Any <Project>(), Arg.Any <SceneAsset>()).Returns(sceneWrapper);

            try {
                Directory.CreateDirectory(projectDirectory);
                var project = await projectService.CreateProject(TestContext.CurrentContext.TestDirectory, projectDirectory);

                Assert.NotNull(project);
                Assert.NotNull(projectService.CurrentProject);
                Assert.AreEqual(project, projectService.CurrentProject);
                Assert.True(File.Exists(project.PathToProject));
            }
            finally {
                if (Directory.Exists(projectDirectory))
                {
                    Directory.Delete(projectDirectory, true);
                }
            }
        }
Beispiel #3
0
    private static void Init()
    {
        Debug.Log("Init");

        // TODO: Should happen on editor scene load...
        LayerManager.Init();

        ZMToggleLayerWindow.ListenToEvents();

        // Init the previous scene to a nonexistent one.
        ZMToggleLayerWindow._previousScene = null;
    }
Beispiel #4
0
    private static void DiffInit()
    {
        // Only call Init() if the scene has changed.
        if (_previousScene != SceneManagerEditor.CurrentScene)
        {
//			Init();
            // Add the new scene.
            LayerManager.AddActiveScene();

            ZMToggleLayerWindow._previousScene = SceneManagerEditor.CurrentScene;
            Debug.Log("update previous scene");
        }
    }
Beispiel #5
0
    private static LayerConfiguration GetConfigurationForScene(SceneWrapper scene)
    {
        LayerConfiguration outConfiguration = null;

        if (LayerManager.IsEmpty())
        {
            LayerManager.Init();
        }

        if (scene.IsNull || !_layerConfigurations.TryGetValue(scene, out outConfiguration))
        {
            Debug.LogErrorFormat("LayerManager: Unable to get configuration for scene {0}", scene.Name);
        }

        return(outConfiguration);
    }
    public static Coroutine UnloadScenes(IList <SceneKind> kinds)
    {
        return(CorouWaiter.Start(GetRoutine()));

        IEnumerator GetRoutine()
        {
            var operations = new List <Coroutine>(kinds.Count);

            foreach (var kind in kinds)
            {
                var wrapper = SceneWrapper.GetWrapper(kind);
                operations.Add(wrapper.Unload());
            }
            foreach (var operation in operations)
            {
                yield return(operation);
            }
            yield break;
        }
    }
Beispiel #7
0
    public static bool IsSceneInitialized(SceneWrapper scene)
    {
        var configuration = LayerManager.GetConfigurationForScene(scene);

        return(configuration.IsInitialized());
    }