public virtual void SaveScene(ProjectItem scene, ProjectManagerCallback callback) { if (SceneSaving != null) { SceneSaving(this, new ProjectManagerEventArgs(scene)); } GameObject extraData = new GameObject(); ExtraSceneData saveLoad = extraData.AddComponent <ExtraSceneData>(); saveLoad.Selection = RuntimeSelection.objects; PersistentScene persistentScene = PersistentScene.CreatePersistentScene( typeof(SealTeam4.GameManager), typeof(SealTeam4.GameManagerAssistant), typeof(SealTeam4.RuntimeEditorUltiltes), typeof(UnityEngine.Networking.NetworkIdentity) ); if (scene.Internal_Data == null) { scene.Internal_Data = new ProjectItemData(); } scene.Internal_Data.RawData = m_serializer.Serialize(persistentScene); Destroy(extraData); m_project.Save(scene, false, saveCompleted => { m_project.UnloadData(scene); m_activeScene = scene; if (callback != null) { callback(); } if (SceneSaved != null) { SceneSaved(this, new ProjectManagerEventArgs(scene)); } }); }
protected void CompleteSceneLoading(ProjectItem scene, ProjectManagerCallback callback, bool isEnabled, PersistentScene persistentScene) { PersistentScene.InstantiateGameObjects(persistentScene); m_project.UnloadData(scene); ExtraSceneData extraData = FindObjectOfType <ExtraSceneData>(); RuntimeUndo.Enabled = false; RuntimeSelection.objects = extraData.Selection; RuntimeUndo.Enabled = isEnabled; Destroy(extraData.gameObject); m_activeScene = scene; if (callback != null) { callback(); } RaiseSceneLoaded(scene); }
public virtual void SaveScene(ProjectItem scene, ProjectManagerCallback callback) { if (SceneSaving != null) { SceneSaving(this, new ProjectManagerEventArgs(scene)); } GameObject extraData = new GameObject(); ExtraSceneData saveLoad = extraData.AddComponent <ExtraSceneData>(); saveLoad.Selection = m_editor.Selection.objects; PersistentScene persistentScene = PersistentScene.CreatePersistentScene(); if (scene.Internal_Data == null) { scene.Internal_Data = new ProjectItemData(); } scene.Internal_Data.RawData = m_serializer.Serialize(persistentScene); Destroy(extraData); m_project.Save(scene, false, saveCompleted => { m_project.UnloadData(scene); m_activeScene = scene; if (callback != null) { callback(); } if (SceneSaved != null) { SceneSaved(this, new ProjectManagerEventArgs(scene)); } }); }
public static void LoadScene() { string path = EditorUtility.OpenFilePanel("Open Scene", Application.persistentDataPath, "rtsc"); if (path.Length != 0) { IProject project = Dependencies.Project; ISerializer serializer = Dependencies.Serializer; project.Load(new[] { path }, loadDataCompleted => { ProjectItem scene = loadDataCompleted.Data[0]; PersistentScene persistentScene = serializer.Deserialize <PersistentScene>(scene.Internal_Data.RawData); PersistentScene.InstantiateGameObjects(persistentScene); project.UnloadData(scene); ExtraSceneData extraData = Object.FindObjectOfType <ExtraSceneData>(); Object.DestroyImmediate(extraData.gameObject); }); } }