private void LoadData() { _stateData = null; _selectedIndex = -1; EditorHelpers.LoadStateRawDatas(); }
public StateRawData Clone() { var c = new StateRawData(ID) { RawData = RawData, Sync = Sync }; return(c); }
private bool DrawLoadService() { EditorGUILayout.BeginHorizontal(); GUI.backgroundColor = EditorHelpers.orangeColor; if (GUILayout.Button("Load", GUILayout.Width(60))) { LoadData(); } GUI.backgroundColor = EditorHelpers.yellowColor; if (GUILayout.Button("New", GUILayout.Width(60))) { var newData = new StateRawData("New State " + _newNameSufix); ++_newNameSufix; EditorHelpers.AllStates.Insert(0, newData); EditorHelpers.InitStateNames(); _selectedIndex = 0; _stateData = newData; ShowNotification(new GUIContent("New State added.")); _dirty = true; } GUI.backgroundColor = EditorHelpers.greenColor; if (GUILayout.Button("Save", GUILayout.Width(60))) { Save(); } GUI.backgroundColor = _backgroundColor; EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (EditorHelpers.AllStates == null) { EditorGUILayout.HelpBox("It seems that there is no data... try reopening the editor.", MessageType.Error); return(false); } if (EditorHelpers.AllStates.Count > 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("States:", GUILayout.Width(100)); int oldIntValue = _selectedIndex; _selectedIndex = EditorGUILayout.Popup(oldIntValue, EditorHelpers.StateNames, GUILayout.Width(250)); if (oldIntValue != _selectedIndex) { _stateData = EditorHelpers.AllStates [_selectedIndex]; } if (_stateData != null) { GUI.backgroundColor = EditorHelpers.blueColor; if (GUILayout.Button("Duplicate", GUILayout.Width(70))) { var newData = _stateData.Clone(); if (newData != null) { newData.ID = string.Format("{0}(Clone)", _stateData.ID); EditorHelpers.AllStates.Insert(0, newData); EditorHelpers.InitStateNames(); _selectedIndex = 0; _stateData = newData; } ShowNotification(new GUIContent("State duplicated.")); _dirty = true; } GUI.backgroundColor = EditorHelpers.redColor; if (GUILayout.Button("Delete", GUILayout.Width(70))) { if (EditorUtility.DisplayDialog("Deleting State!", "Are you sure you want to delete State'" + _stateData.ID + "'?", "Yes, Delete it.", "No!")) { EditorHelpers.gameDB.DeleteStateRawData(_stateData.GetTableName(), _stateData.ID); EditorHelpers.AllStates.Remove(_stateData); EditorHelpers.InitStateNames(); _selectedIndex = -1; _stateData = null; ShowNotification(new GUIContent("State deleted.")); return(false); } } GUI.backgroundColor = _backgroundColor; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); } return(_stateData != null); }