public static void Menu() { EditorLSDatabaseWindow window = EditorWindow.GetWindow <EditorLSDatabaseWindow> (); window.titleContent = new GUIContent("Lockstep Database"); window.minSize = new Vector2(400, 100); window.Show(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { float height = 15f; Rect drawPos = position; drawPos.yMax = drawPos.yMin + height; DataCodeAttribute dca = this.attribute as DataCodeAttribute; if (dca == null) { EditorGUI.LabelField(drawPos, "No attribute found"); } else if (EditorLSDatabaseWindow.Window == null || EditorLSDatabaseWindow.Window.IsLoaded == false) { if (GUI.Button(drawPos, new GUIContent("No database loaded", "Click to open the database manager and load a database."))) { if (EditorLSDatabaseWindow.Window == null) { EditorLSDatabaseWindow.Menu(); } else { EditorLSDatabaseWindow.Window.Show(); } } } else { DataHelper helper; if (!EditorLSDatabaseWindow.Window.DatabaseEditor.DataHelpers.TryGetValue(dca.TargetDataName, out helper)) { Debug.LogError("Data code '" + dca.TargetDataName + "' was not found in the current database"); } else { DataItem[] data = helper.Data; GUIContent[] dataContents = new GUIContent[data.Length + 1]; if (property.isArray && property.type != "string") { int arraySize = property.arraySize; arraySize = EditorGUI.IntField(drawPos, "Size", arraySize); property.arraySize = arraySize; for (int n = 0; n < arraySize; n++) { SerializedProperty element = property.GetArrayElementAtIndex(n); DrawElement(element, dataContents, data, drawPos, label); } } else { DrawElement(property, dataContents, data, drawPos, label); } } } accumulatedHeight = drawPos.yMax - position.yMin; }
public void Initialize(EditorLSDatabaseWindow window, LSDatabase database) { this.MainWindow = window; Database = database; InitializeData(); for (int i = 0; i < DataItemInfos.Count; i++) { DataItemInfo info = DataItemInfos[i]; CreateDataHelper(info); } }
public void Initialize(EditorLSDatabaseWindow window, LSDatabase database, out bool valid) { this.MainWindow = window; Database = database; InitializeData(); IsValid = true; for (int i = 0; i < DataItemInfos.Count; i++) { DataItemInfo info = DataItemInfos[i]; bool isValid; CreateDataHelper(info, out isValid); if (!isValid) { Debug.LogError("Database does not match database type described by the database editor. Make sure Lockstep_Database.asset is the correct database type."); IsValid = false; break; } } valid = IsValid; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { float height = 15f; Rect drawPos = position; drawPos.yMax = drawPos.yMin + height; DataCodeAttribute dca = this.attribute as DataCodeAttribute; if (dca == null) { EditorGUI.LabelField(drawPos, "No attribute found"); } else if (EditorLSDatabaseWindow.Window == null || EditorLSDatabaseWindow.Window.IsLoaded == false) { if (GUI.Button(drawPos, new GUIContent("No database loaded", "Click to open the database manager and load a database."))) { if (EditorLSDatabaseWindow.Window == null) { EditorLSDatabaseWindow.Menu(); } else { EditorLSDatabaseWindow.Window.Show(); } } } else { DataHelper helper; if (!EditorLSDatabaseWindow.Window.DatabaseEditor.DataHelpers.TryGetValue(dca.TargetDataName, out helper)) { Debug.LogError("Data code '" + dca.TargetDataName + "' was not found in the current database"); } else { DataItem[] data = helper.Data; GUIContent[] dataContents = new GUIContent[data.Length]; if (property.isArray && property.type != "string") { int arraySize = property.arraySize; arraySize = EditorGUI.IntField(drawPos, "Size", arraySize); property.arraySize = arraySize; for (int n = 0; n < arraySize; n++) { SerializedProperty element = property.GetArrayElementAtIndex(n); string curName = element.stringValue; int index = -1; for (int i = 0; i < data.Length; i++) { string name = data [i].Name; if (curName.Equals(name)) { index = i; } GUIContent content = new GUIContent(name); dataContents [i] = content; } //label.tooltip += dca.TargetDataName; int newIndex = EditorGUI.Popup(drawPos, label, index, dataContents); if (newIndex >= 0 && newIndex < dataContents.Length) { element.stringValue = dataContents [newIndex].text; } } } else { string curName = property.stringValue; int index = -1; for (int i = 0; i < data.Length; i++) { string name = data [i].Name; if (curName.Equals(name)) { index = i; } GUIContent content = new GUIContent(name); dataContents [i] = content; } //label.tooltip += dca.TargetDataName; int newIndex = EditorGUI.Popup(drawPos, label, index, dataContents); if (newIndex >= 0 && newIndex < dataContents.Length) { property.stringValue = dataContents [newIndex].text; } } } } accumulatedHeight = drawPos.yMax - position.yMin; }
public void Initialize(EditorLSDatabaseWindow window, LSDatabase database) { this.MainWindow = window; Database = database; InitializeData (); for (int i = 0; i < DataItemInfos.Count; i++) { DataItemInfo info = DataItemInfos[i]; CreateDataHelper (info); } }
public void Initialize(EditorLSDatabaseWindow window, LSDatabase database, out bool valid) { this.MainWindow = window; Database = database; InitializeData (); IsValid = true; for (int i = 0; i < DataItemInfos.Count; i++) { DataItemInfo info = DataItemInfos[i]; bool isValid; CreateDataHelper (info, out isValid); if (!isValid) { Debug.LogError ("Database does not match database type described by the database editor. Make sure Lockstep_Database.asset is the correct database type."); IsValid = false; break; } } valid = IsValid; }