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, out bool valid) { this.MainWindow = window; Database = database; InitializeData(); bool isValid = true; for (int i = 0; i < DataItemInfos.Count; i++) { DataItemInfo info = DataItemInfos [i]; bool bufferValid; CreateDataHelper(info, out bufferValid); if (!bufferValid) { 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; }