internal static void EraseSessionStateKeys() { int numKeys = SessionState.GetInt(k_GlobalProfileVariablesCountKey, 0); EraseSessionStateKeys(0, numKeys); SessionState.EraseInt(k_GlobalProfileVariablesCountKey); }
protected static void ClearPathsFromSession(string varName, string prefix) { var n = SessionState.GetInt(string.Format(prefix, varName), 0); SessionState.EraseInt(string.Format(prefix, varName)); for (int i = 0; i < n; i++) { SessionState.EraseString(string.Format(prefix + "_{1}", varName, i)); } }
public void TearDown() { SessionState.EraseInt(GridPaletteBrushes.s_SessionStateLastUsedBrush); GridPaintingState.gridBrush = GridPaletteBrushes.brushes[0]; GridPaintActiveTargetsPreferences.restoreEditModeSelection = true; if (AssetDatabase.GetAllAssetPaths().Contains(path + "/" + name + ".prefab")) { AssetDatabase.DeleteAsset(path + "/" + name + ".prefab"); } if (AssetDatabase.GetAllAssetPaths().Contains(path2 + "/" + name2 + ".prefab")) { AssetDatabase.DeleteAsset(path2 + "/" + name2 + ".prefab"); } if (AssetDatabase.LoadAllAssetsAtPath(defaultTemporaryPalettePath).Length > 0) { AssetDatabase.DeleteAsset(defaultTemporaryPalettePath); } if (AssetDatabase.LoadAllAssetsAtPath(temporaryPalettePath).Length > 0) { AssetDatabase.DeleteAsset(temporaryPalettePath); } if (AssetDatabase.LoadAllAssetsAtPath(temporaryAssetPath).Length > 0) { AssetDatabase.DeleteAsset(temporaryAssetPath); } if (AssetDatabase.LoadAllAssetsAtPath(temporaryTilePath).Length > 0) { AssetDatabase.DeleteAsset(temporaryTilePath); } if (AssetDatabase.IsValidFolder("Assets/Temp")) { FileUtil.DeleteFileOrDirectory("Assets/Temp"); FileUtil.DeleteFileOrDirectory("Assets/Temp.meta"); AssetDatabase.Refresh(); } GridPaletteBrushes.FlushCache(); GridPalettes.CleanCache(); if (m_Window != null) { m_Window.Close(); m_Window = null; } }
public static void ResetAllSessionSettings(string prefix, string settingsDefaults = null) { SessionState.EraseString(string.Format(prefix, k_SessionSettingsName)); // Set the defaults of the settings. // If there exists a Default Preset for the Convert/Export settings, then if the project settings are modified, // the Default Preset will be reloaded instead of the project settings. Therefore, set them explicitely if projects settings desired. if (!string.IsNullOrEmpty(settingsDefaults)) { SessionState.SetString(string.Format(prefix, k_SessionSettingsName), settingsDefaults); } ClearPathsFromSession(k_SessionFbxPathsName, prefix); SessionState.EraseInt(string.Format(prefix, k_SessionSelectedFbxPathName)); ClearPathsFromSession(k_SessionPrefabPathsName, prefix); SessionState.EraseInt(string.Format(prefix, k_SessionSelectedPrefabPathName)); }
public void TopbarGUI() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Missions", GUILayout.Width(70)); selectedMissionIndex = EditorGUILayout.Popup(selectedMissionIndex, MissionList, EditorStyles.toolbarPopup); if (EditorGUI.EndChangeCheck() && Missions.Any()) { selectedMission = Missions[selectedMissionIndex]; SessionState.SetInt("MissionEditor_LastSelectedMission", selectedMissionIndex); missionEditor = Editor.CreateEditor(selectedMission); QuickSwitchScenes((Mission)Missions[selectedMissionIndex]); } EditorGUI.BeginDisabledGroup(Missions.Count == 0); if (GUILayout.Button("-", EditorStyles.toolbarButton)) { if (EditorUtility.DisplayDialog("Delete Mission?", "Are you sure you want to delete Mission: " + Missions[selectedMissionIndex].Mission_Name + "? This action cannot be undone!" , "Delete", "Cancel")) { RemoveAssets(Missions[selectedMissionIndex]); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath((Mission)Missions[selectedMissionIndex])); } SessionState.EraseInt("MissionEditor_LastSelectedMission"); } EditorGUI.EndDisabledGroup(); if (GUILayout.Button("+", EditorStyles.toolbarButton)) { MissionCreator.GetWindow <MissionCreator>(); MissionCreator.onMissionCreated += () => { this.Focus(); selectedMission = MissionCreator.LastCreatedMission; missionEditor = Editor.CreateEditor(selectedMission); selectedMissionIndex = GetIndexOfCurrentMission(); SessionState.SetInt("MissionEditor_LastSelectedMission", selectedMissionIndex); }; } EditorGUILayout.EndHorizontal(); }
public void SetUp() { AssetDatabase.CreateFolder("Assets", "Temp"); AssetDatabase.CopyAsset(defaultPalettePath, defaultTemporaryPalettePath); AssetDatabase.Refresh(); var gridPalette = AssetDatabase.LoadAssetAtPath(defaultTemporaryPalettePath, typeof(GridPalette)); if (gridPalette == null) { GridPalette palette = GridPalette.CreateInstance <GridPalette>(); palette.name = "Palette Settings"; palette.cellSizing = GridPalette.CellSizing.Automatic; AssetDatabase.AddObjectToAsset(palette, defaultTemporaryPalettePath); AssetDatabase.ForceReserializeAssets(new string[] { defaultTemporaryPalettePath }); } AssetDatabase.Refresh(); SessionState.EraseInt(GridPaletteBrushes.s_SessionStateLastUsedBrush); GridPaintingState.gridBrush = GridPaletteBrushes.brushes[0]; }
private static void SetProjectDirty() { SessionState.EraseInt(kStateResolvePackages); }
public override bool Render() { if (this.team == null) { return(false); } bool delete = false; bool close = false; EditorGUILayout.ScrollViewScope scrollScope = new EditorGUILayout.ScrollViewScope(scroll); using (scrollScope) { scroll = scrollScope.scrollPosition; EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); if (GUILayout.Button("X", EditorStyles.toolbarButton, GUILayout.Width(20))) { Undo.RecordObject(mission, "Remove Team"); mission.Teams.Remove(this.team); mission.RefreshCharacterDictionary(); close = true; } EditorGUILayout.LabelField("Team: " + mission.GetTeamIndex(this.team)); if (GUILayout.Button("Close", EditorStyles.toolbarButton, GUILayout.Width(55))) { close = true; } EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); string _name = EditorGUILayout.TextField("Team Name: ", team.TeamName); Color tColor = EditorGUILayout.ColorField(team.TeamColor); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(mission, "Modify Team"); team.TeamName = _name; team.TeamColor = tColor; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUI.indentLevel++; EditorGUILayout.LabelField("Members", EditorStyles.miniBoldLabel); List <Character> characters = team.members; if (GUILayout.Button("+", GUILayout.Width(30))) { Undo.RecordObject(mission, "Add Character"); GenericMenu CreateMenu = new GenericMenu(); CreateMenu.AddItem(new GUIContent("Add new"), false, CreateNewCharacter); foreach (Character chara in EditorTools.CharaDatabase.commonCharacters) { CreateMenu.AddItem(new GUIContent("Common/" + chara._Name), false, GetCharacter, chara); } foreach (Character chara in EditorTools.CharaDatabase.uniqueCharacters) { CreateMenu.AddItem(new GUIContent("Unique/" + chara._Name), false, GetCharacter, chara); } CreateMenu.ShowAsContext(); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel++; for (int q = 0; q < characters.Count; q++) { Character chara = characters[q]; var v = new EditorGUILayout.HorizontalScope(); using (v) { GUILayout.Space(20 * EditorGUI.indentLevel); if (GUILayout.Button(chara._Name, EditorStyles.label, GUILayout.Width(150))) { CharacterEditor newEditor = EditorWindow.CreateInstance <CharacterEditor>(); newEditor.Do(chara, mission, mission, false); SessionState.SetInt("CharacterEditor_LastCharacterIndex", q); if (this.parent != null) { this.parent.auxWindow = newEditor; newEditor.SetParent(this.parent); } else { newEditor.Show(); } } if (this.parent != null) { if (GUILayout.Button("Pop", EditorStyles.miniButtonLeft)) { CharacterEditor newEditor = EditorWindow.CreateInstance <CharacterEditor>(); newEditor.Do(chara, mission, mission, false); newEditor.Show(); parent.auxWindow = null; this.parent = null; } } if (GUILayout.Button("X", EditorStyles.miniButtonRight)) { Undo.RecordObject(mission, "Remove Character"); characters.Remove(chara); mission.attatchedObjects.Remove(chara.SpawnCondition); string path = AssetDatabase.GetAssetPath(chara.SpawnCondition); AssetDatabase.DeleteAsset(path); SessionState.EraseInt("CharacterEditor_LastCharacterIndex"); } } if (Event.current.button == 1 && v.rect.Contains(Event.current.mousePosition)) { CharacterContextMenu(v.rect, chara); } // EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); } return(delete || close); }