/// <summary> /// Creates project from given json /// </summary> /// <param name="project"></param> public bool CreateProject(IO.Swagger.Model.Project project, bool allowEdit) { Debug.Assert(ActionsManager.Instance.ActionsReady); if (Project != null) { return(false); } Project = project; this.AllowEdit = allowEdit; LoadSettings(); bool success = UpdateProject(project, true); if (success) { ProjectChanged = false; OnLoadProject?.Invoke(this, EventArgs.Empty); } ProjectLoaded = success; return(success); }
private static void LoadContext(UTinyEditorContext context, bool isChanged) { Assert.IsNotNull(context); UTinyModificationProcessor.ClearChanged(); // @NOTE Loading a project can cause a Unity scene to change or be loaded during this operation we dont want to trigger a save using (new UTinyModificationProcessor.DontSaveScope()) { // Cleanup the previous context if (context != EditorContext) { EditorContext?.Unload(); } // Load the new context EditorContext = context; EditorContext.Load(); // Setup the initial state s_WorkspaceVersion = EditorContext.Workspace.Version; OnLoadProject?.Invoke(EditorContext.Project); // Flush the Undo stack EditorContext.Undo.Update(); // Listen for ANY changes and flag the project as changed (*) EditorContext.Caretaker.OnObjectChanged += (originator, memento) => { UTinyModificationProcessor.MarkChanged(); }; EditorContext.Undo.OnUndoPerformed += UTinyModificationProcessor.MarkChanged; EditorContext.Undo.OnRedoPerformed += UTinyModificationProcessor.MarkChanged; } if (isChanged) { UTinyModificationProcessor.MarkChanged(); } }