public static void RevertAnchors(MenuCommand command) { if (EditorApplication.isPlaying) { return; } RectTransform rectTransform = (RectTransform)command.context; string path = RectTransformScenePath(rectTransform); if (!states.ContainsKey(path)) { ToolsDebug.Log($"RectTransformExtension can't revert anchors."); } else { var state = states[path]; rectTransform.pivot = state.defaultPivot; rectTransform.anchorMin = state.defaultAnchorMin; rectTransform.anchorMax = state.defaultAnchorMax; rectTransform.sizeDelta = state.defaultSize; rectTransform.anchoredPosition = state.defaultPosition; states.Remove(path); } SaveStates(); }
public static void LoadFirstScene() { ToolsDebug.Log("LoadFirstScene " + cursor + " " + sceneHistoryList.Count); userLoadedScene = true; #if UNITY_5_0_OR_NEWER || UNITY_2017_1_OR_NEWER EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); if (sceneHistoryList.Count >= maxLength) { sceneHistoryList.RemoveAt(0); sceneHistoryList.Add(new SceneRef(EditorSceneManager.GetActiveScene().path)); } else { sceneHistoryList.Add(new SceneRef(EditorSceneManager.GetActiveScene().path)); } #else EditorApplication.SaveCurrentSceneIfUserWantsTo(); if (sceneHistoryList.Count >= maxLength) { sceneHistoryList.RemoveAt(0); sceneHistoryList.Add(EditorApplication.currentScene); } else { sceneHistoryList.Add(EditorApplication.currentScene); } #endif #if UNITY_5_0_OR_NEWER || UNITY_2017_1_OR_NEWER if (EditorSceneManager.sceneCountInBuildSettings != 0) { if (EditorSceneManager.GetSceneByBuildIndex(0) != null) { EditorSceneManager.OpenScene(EditorBuildSettings.scenes[0].path, OpenSceneMode.Single); } else { ToolsDebug.Log("Not exist scenes in builds settings. "); } } else { ToolsDebug.Log("Not exist scenes in builds settings. "); } #else if (EditorBuildSettings.scenes.Length != 0) { EditorApplication.OpenScene(EditorBuildSettings.scenes[0].path); } else { ToolsDebug.Log("Not exist scenes in builds settings. "); } #endif }
static SceneHistoryMenu() { #if UNITY_5_0_OR_NEWER || UNITY_2017_1_OR_NEWER ToolsDebug.Log("Init history scene"); EditorSceneManager.sceneOpened += OnSceneOpenedInEditor; sceneHistoryList.Add(new SceneRef(SceneManager.GetActiveScene().path)); #else EditorApplication.hierarchyWindowChanged += CheckSceneUpdated; sceneHistoryList.Add(new SceneRef(EditorApplication.currentScene)); #endif cursor = 0; }
/// <summary> /// Handler for open scene in editor event. /// </summary> /// <param name="scene">Scene</param> /// <param name="mode">Scene mode.</param> public static void OnSceneOpenedInEditor(Scene scene, OpenSceneMode mode) { ToolsDebug.Log("OnSceneOpenedInEditor " + sceneHistoryList.Count); foreach (string s in sceneHistoryList) { ToolsDebug.Log(s); } //Just in editor, non runtime if (!Application.isPlaying && mode == OpenSceneMode.Single) { AddedSceneInHistory(new SceneRef(scene.name)); } }
public static void LoadPreviousScene() { userLoadedScene = true; ToolsDebug.Log("LoadPrevScene " + cursor + " " + sceneHistoryList.Count); if (cursor <= 0) { return; } #if UNITY_5_0_OR_NEWER || UNITY_2017_1_OR_NEWER EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); #else EditorApplication.SaveCurrentSceneIfUserWantsTo(); #endif cursor--; #if UNITY_5_0_OR_NEWER || UNITY_2017_1_OR_NEWER EditorSceneManager.OpenScene(sceneHistoryList[cursor]); #else EditorApplication.OpenScene(sceneHistoryList[cursor]); #endif }