public override void OnInspectorGUI() { base.OnInspectorGUI(); SerializedObject serializedObject = new SerializedObject(LogoTable.Instance); List <TableColumn> columns = new List <TableColumn>() { new TableColumn("G", 28f), new TableColumn("U", 22f), new TableColumn("I ", 35f), }; List <List <TableEntry> > rows = new List <List <TableEntry> >(); LogoTable targetObject = LogoTable.Instance; for (int i = 0; i < targetObject.logoLines.Count; i++) { rows.Add(new List <TableEntry>() { new PropertyEntry(serializedObject, string.Format("logoLines.Array.data[{0}].letter1", i)), new PropertyEntry(serializedObject, string.Format("logoLines.Array.data[{0}].letter2", i)), new PropertyEntry(serializedObject, string.Format("logoLines.Array.data[{0}].color", i)), }); } tableState = GUITable.DrawTable(columns, rows, tableState); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { //Check that it is a collection Match match = Regex.Match(property.propertyPath, "^([a-zA-Z0-9_]*).Array.data\\[([0-9]*)\\]$"); if (!match.Success) { EditorGUI.LabelField(position, label.text, "Use the Table attribute with a collection."); return; } string collectionPath = match.Groups[1].Value; // Check that it's the first element string index = match.Groups[2].Value; if (index != "0") { return; } if (GUILayoutUtility.GetLastRect().width > 1f) { lastRect = GUILayoutUtility.GetLastRect(); } Rect r = new Rect(lastRect.x + 15f, lastRect.y + 35f, lastRect.width, lastRect.height); GUILayout.BeginArea(r); EditorGUI.indentLevel = 0; tableState = GUITable.DrawTable(property.serializedObject.FindProperty(collectionPath), tableState); GUILayout.EndArea(); GUILayout.Space(30f); }
void DrawCustomEntries() { SerializedObject serializedObject = new SerializedObject(SimpleExample.Instance); List <TableColumn> columns = new List <TableColumn>() { new TableColumn("String", 60f), new TableColumn("Float", 50f), new TableColumn("Object", 110f), new TableColumn("", 100f) { enabledTitle = false }, }; List <List <TableEntry> > rows = new List <List <TableEntry> >(); SimpleExample targetObject = (SimpleExample)serializedObject.targetObject; for (int i = 0; i < targetObject.simpleObjects.Count; i++) { SimpleExample.SimpleObject entry = targetObject.simpleObjects[i]; rows.Add(new List <TableEntry>() { new LabelEntry(entry.stringProperty), new PropertyEntry(serializedObject, string.Format("simpleObjects.Array.data[{0}].floatProperty", i)), new PropertyEntry(serializedObject, string.Format("simpleObjects.Array.data[{0}].objectProperty", i)), new ActionEntry("Reset", () => entry.Reset()), }); } tableState = GUITable.DrawTable(columns, rows, tableState); }
void DrawCustomProperties() { SerializedObject serializedObject = new SerializedObject(SimpleExample.Instance); tableState = GUITable.DrawTable(serializedObject.FindProperty("simpleObjects"), new List <string>() { "floatProperty", "objectProperty" }, tableState); }
void DrawCustomColumns() { SerializedObject serializedObject = new SerializedObject(SimpleExample.Instance); List <PropertyColumn> propertyColumns = new List <PropertyColumn>() { new PropertyColumn("stringProperty", "String", 60f), new PropertyColumn("floatProperty", "Float", 50f) { optional = true }, new PropertyColumn("objectProperty", "Object", 110f) { enabledTitle = false, optional = true }, }; tableState = GUITable.DrawTable(serializedObject.FindProperty("simpleObjects"), propertyColumns, tableState); }
protected override void OnGUI() { base.OnGUI(); var width = position.width / 2; EditorGUILayout.BeginHorizontal(); _scrollPositionEntities = EditorGUILayout.BeginScrollView(_scrollPositionEntities, GUILayout.Width(width)); if (_entityTable == null) { ShowEntities(); } _entityTable.DrawTable(); EditorGUILayout.EndScrollView(); _scrollPositionComponents = EditorGUILayout.BeginScrollView(_scrollPositionComponents, GUILayout.Width(width)); ShowEntityComponents(); EditorGUILayout.EndScrollView(); EditorGUILayout.EndHorizontal(); }
void DrawCustomColumnsWithSelector() { SerializedObject serializedObject = new SerializedObject(SimpleExample.Instance); List <SelectorColumn> selectorColumns = new List <SelectorColumn>() { new SelectorColumn(prop => new LabelEntry(prop.stringValue), "stringProperty", "String", 60f), new SelectorColumn(prop => new LabelEntry(prop.floatValue.ToString()), "floatProperty", "Float", 50f) { optional = true }, new SelectorColumn(prop => new LabelEntry(prop.objectReferenceValue.name), "objectProperty", "Object", 110f) { enabledTitle = false, optional = true }, }; tableState = GUITable.DrawTable(serializedObject.FindProperty("simpleObjects"), selectorColumns, tableState); }
private void DrawCachedPlayerEditorData() { if (guiTablePlayerEditorData == null) { RefreshDataTable(); } EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); PagingTable.AmountToShowPerPage = EditorGUILayout.IntField("Show Count (Pagination)", PagingTable.AmountToShowPerPage); if (EditorGUI.EndChangeCheck()) { RefreshDataTable(false); } if (GUILayout.Button("<")) { PagingTable.PageIndex -= 1; RefreshDataTable(false); } EditorGUILayout.LabelField($"{PagingTable.PageIndex + 1}/{PagingTable.MaxPage()}"); if (GUILayout.Button(">")) { PagingTable.PageIndex += 1; RefreshDataTable(false); } EditorGUILayout.EndHorizontal(); guiTablePlayerEditorData.DrawTable(); if (GUILayout.Button("Refresh Table")) { RefreshDataTable(); } }
void DrawSimple() { tableState = GUITable.DrawTable(serializedObject.FindProperty("simpleObjects"), tableState); }
void DrawObjectsTable() { SerializedObject serializedObject = new SerializedObject(AdvancedExample.Instance); List <TableColumn> columns = new List <TableColumn>() { new TableColumn("Name", 60f), new TableColumn("Prefab", 50f) { enabledEntries = false, optional = true }, new TableColumn("Type", 50f) { optional = true }, new TableColumn("Health", 50f), new TableColumn("Speed", 50f), new TableColumn("Color", 50f) { optional = true }, new TableColumn("Can Swim", 30f) { optional = true }, new TableColumn("Spawners", 450f) { optional = true }, new TableColumn("Intro (shared by type)", 110f) { optional = true }, new TableColumn("Instantiation", 110f) { optional = true } }; List <List <TableEntry> > rows = new List <List <TableEntry> >(); AdvancedExample targetObject = (AdvancedExample)serializedObject.targetObject; for (int i = 0; i < targetObject.enemies.Count; i++) { Enemy enemy = targetObject.enemies[i]; int sentenceIndex = targetObject.introSentences.FindIndex(s => s.enemyType == enemy.type); rows.Add(new List <TableEntry>() { new LabelEntry(enemy.name), new PropertyEntry(serializedObject, string.Format("enemies.Array.data[{0}]", i)), new PropertyEntry(new SerializedObject(enemy), "type"), new PropertyEntry(new SerializedObject(enemy), "health"), new PropertyEntry(new SerializedObject(enemy), "speed"), new PropertyEntry(new SerializedObject(enemy), "color"), new PropertyEntry(new SerializedObject(enemy), "canSwim"), new SpawnersEntry(new SerializedObject(enemy), "spawnersMask"), new PropertyEntry(serializedObject, string.Format("introSentences.Array.data[{0}].sentence", sentenceIndex)), new ActionEntry("Instantiate", () => enemy.Instantiate()), }); } tableState = GUITable.DrawTable(columns, rows, tableState); }