private void DrawTableStructureCreateField() { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Create", EditorStatics.Width_100)) { if (tableSO.Table.CreateColumn(newColumnName)) { newColumnName = string.Empty; GUI.FocusControl(null); } } // Spacing EditorStatics.CreateLabelField("", EditorStatics.Width_10); newColumnName = EditorStatics.CreateTextField( "Column Name", "", newColumnName, EditorStatics.Width_300 ); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); }
//////////////////////////////////////////////////////////////////////// #region Mouse Position Information private void DrawMousePositionUI(Vector3 _mousePosition) { float _y = _RectInterfaceControlSize + rectMouseBoxOffset.y; rectMouseBox.Set(rectMouseBoxOffset.x, _y, rectMouseBoxSize.x, rectMouseBoxSize.y); GUILayout.BeginArea(rectMouseBox, "MOUSE POSITION", GUI.skin.GetStyle("Window")); if (PerspectiveType == PerspectiveType.Top_XZ) { string _text = string.Format( "X: ({0}) Z: ({1})", _mousePosition.x, _mousePosition.z ); EditorStatics.CreateLabelField(_text, EditorStatics.Width_350); } else { string _text = string.Format( "Z: ({0}) Y: ({1})", _mousePosition.z, _mousePosition.y ); EditorStatics.CreateLabelField(_text, EditorStatics.Width_350); } GUILayout.EndArea(); }
protected override void OnDrawAfterInterfaceMoveLine() { base.OnDrawAfterInterfaceMoveLine(); EditorGUILayout.BeginHorizontal(); EditorStatics.CreateLabelField("Display", string.Empty, EditorStatics.Width_70); viewType = (ViewType)EditorGUILayout.EnumPopup( string.Empty, viewType, EditorStatics.Width_90 ); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorStatics.CreateLabelField("Perspective", string.Empty, EditorStatics.Width_70); perspectiveType = (PerspectiveType)EditorGUILayout.EnumPopup( string.Empty, perspectiveType, EditorStatics.Width_90 ); EditorGUILayout.EndHorizontal(); }
private void DrawTableStructureColumns() { int _columnCount = tableSO.Table.ColumnCount; for (int _i = 0; _i < _columnCount; _i++) { if (_i != 0) { EditorGUILayout.Space(); } EditorGUILayout.BeginHorizontal(); // Display row index EditorStatics.CreateLabelField(_i.ToString(), EditorStatics.Width_50); ITableColumn _column = tableSO.Table.GetColumnByIndex(_i); EditorStatics.CreateLabelField( _column.ColumnName, EditorStatics.Width_210 ); _column.ColumnNameEditor = EditorStatics.CreateTextField( "", "", _column.ColumnNameEditor, EditorStatics.Width_300 ); ///Calls update method which will invoke OnRowUpdated event if (GUILayout.Button("Update", EditorStatics.Width_80)) { if (!string.IsNullOrEmpty(_column.ColumnNameEditor)) { if (tableSO.Table.UpdateColumnName(_column.ColumnNameEditor, _column)) { _column.ColumnNameEditor = string.Empty; } GUI.FocusControl(null); } } if (GUILayout.Button("Delete", EditorStatics.Width_80)) { tableSO.Table.RemoveColumn(_column); EditorGUILayout.EndHorizontal(); return; } EditorGUILayout.EndHorizontal(); } }
/// <summary> /// Edits the path header. /// </summary> /// <returns>True if path was removed from the list</returns> private bool EditPathHeader(SpawnPoint _point, Path _path, int _pathIndex) { EditorStatics.CreateLabelField("", EditorStatics.Width_27); // Remove spawn point if (GUILayout.Button(EditorStatics.StringRemoveSign, EditorStatics.Width_30)) { _point.RemoveWithID(_path.ID); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); return(true); } EditDisplay(ContentHandles, ref _path.IsDisplayingHandles); EditDisplay(ContentGizmos, ref _path.IsDisplayingGizmo); EditDisplay(ContentLabels, ref _path.IsDisplayingLabel); // Keyboard enable/disable if (currentPathKeyboard == _pathIndex) { // Enable adding pathpoints to this path with keyboard EditorStatics.GUIPreColor = GUI.backgroundColor; GUI.backgroundColor = Color.green; if (GUILayout.Button(contentKeyboard, EditorStatics.Width_30)) { currentPathKeyboard = -1; } GUI.backgroundColor = EditorStatics.GUIPreColor; } else { // Enable adding pathpoints to this path with keyboard EditorStatics.GUIPreColor = GUI.backgroundColor; GUI.backgroundColor = Color.red; if (GUILayout.Button(contentKeyboard, EditorStatics.Width_30)) { currentPathKeyboard = _pathIndex; } GUI.backgroundColor = EditorStatics.GUIPreColor; } return(false); }
private void DrawTableRow() { if (currentRowIndex < 0) { return; } TableRow _currentRow = tableSO.Table.GetRowByIndex(currentRowIndex); int _columnCount = tableSO.Table.ColumnCount; for (int _i = 0; _i < _columnCount; _i++) { if (_i != 0) { EditorGUILayout.Space(); } EditorGUILayout.BeginHorizontal(); // Display row index EditorStatics.CreateLabelField(_i.ToString(), EditorStatics.Width_50); ITableRowValue _column = _currentRow.RowColumns[_i]; EditorStatics.CreateLabelField( _column.ColumnName, EditorStatics.Width_210 ); _column.Value = EditorGUILayout.TextArea( _column.Value, GUILayout.MinHeight(100), GUILayout.MaxWidth(460) ); ///Calls update method which will invoke OnRowUpdated event if (GUILayout.Button("Update", EditorStatics.Width_80)) { _column.Update(_column.Value); } EditorGUILayout.EndHorizontal(); } }
private void DrawPaginationBar() { GUILayout.FlexibleSpace(); int _count = tableSO.Table.GetPageCount(currentPerPageValue); int _paginationStart = Mathf.Max(0, currentPage - pagination); int _paginationEnd = Mathf.Min(_count, currentPage + pagination); for (int i = _paginationStart; i < _paginationEnd; i++) { if (i != currentPage) { if (GUILayout.Button((i + 1).ToString(), EditorStatics.Width_27)) { currentPage = i; } } } EditorStatics.CreateLabelField(string.Empty, EditorStatics.Width_30); labelDistance = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 60; currentPerPageValue = EditorStatics.CreateIntPopup( "Per Page", currentPerPageValue, optionsPerPageString, optionsPerPageInt, EditorStatics.Width_140 ); if (currentPerPageValuePrevious != currentPerPageValue) { currentPage = 0; currentPerPageValuePrevious = currentPerPageValue; } EditorGUIUtility.labelWidth = labelDistance; }
private void OnGUI() { SelectSO(); if (!so) { return; } Undo.RecordObject(so, "Undo Spawn Point"); EditorGUILayout.BeginHorizontal(); EditorStatics.CreateLabelField(string.Empty, EditorStatics.Width_10); if (GUILayout.Button("Graph", EditorStatics.Width_70)) { graph = new GraphSpawnPointEditorWindow(); graph.Enable(so); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false); InterfaceControls(); InterfacePreview(); InterfaceSpawnPoints(); EditorGUILayout.Space(); GUILayout.EndScrollView(); // If not called, changes to scriptable object are lost when Unity is restarted EditorUtility.SetDirty(so); }
private void DrawColumns() { GUIStyle _style = EditorStatics.GetBoxStyle(0, 0, 2, 2, 2, 2, 5, 5); EditorGUILayout.BeginVertical(_style); EditorGUILayout.BeginHorizontal(); // Edit row (Width_50), insert (Width_50), remove (Width_50) width in DrawRows() EditorStatics.CreateLabelField("", EditorStatics.Width_150); // Spacing fix EditorStatics.CreateLabelField("", EditorStatics.Width_5); // Shift row up and down (Width_20) width in DrawRows() EditorStatics.CreateLabelField("", EditorStatics.Width_20); EditorStatics.CreateLabelField("", EditorStatics.Width_20); EditorStatics.CreateLabelField("#", EditorStatics.Width_50); int _count = tableSO.Table.ColumnCount; for (int _i = 0; _i < _count; _i++) { EditorStatics.CreateLabelField( tableSO.Table.ColumnNames[_i].ShorterText(10, true), EditorStatics.Width_80, style ); // Push the next one EditorStatics.CreateLabelField("", EditorStatics.Width_5); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
//////////////////////////////////////////////////////////////////////// #region Log private void DisplayLog() { GUILayout.FlexibleSpace(); GUIStyle _style = EditorStatics.GetBoxStyle(20, 10, 10, 10, 15, 15, 15, 15, 600, 100); EditorGUILayout.BeginVertical(_style); scrollPositionLog = GUILayout.BeginScrollView(scrollPositionLog, false, false); logCount = logs.Count; for (int _i = logCount - 1; _i >= 0; _i--) { EditorStatics.CreateLabelField( logs[_i].LogMessage, EditorStatics.Width_500, logs[_i].ActionStatus ? colorLogSuccess : colorLogFail ); } GUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
private void DrawRows() { int _startIndex = currentPage * currentPerPageValue; List <TableRow> _rows = tableSO.Table.GetRows(_startIndex, _startIndex + currentPerPageValue, true); if (_rows == null) { return; } int _count = _rows.Count; for (int _i = 0; _i < _count; _i++) { TableRow _row = _rows[_i]; int _rowIndex = _startIndex + _i; GUIStyle _style = EditorStatics.GetBoxStyle(0, 0, 0, 0, 2, 2, 2, 2, 0, 30); EditorGUILayout.BeginVertical(_style); EditorGUILayout.BeginHorizontal(); // Insert a row before this one if (GUILayout.Button(new GUIContent("Insert", "Insert a row before this one"), EditorStatics.Width_50)) { tableSO.Table.InsertRow(_rowIndex); EditorGUILayout.EndHorizontal(); return; } // Insert a row before this one if (GUILayout.Button("Delete", EditorStatics.Width_50)) { tableSO.Table.RemoveRow(_rowIndex); EditorGUILayout.EndHorizontal(); return; } if (GUILayout.Button("Edit", EditorStatics.Width_50)) { EditTableRow(_rowIndex); } // Shift row to previous index if (GUILayout.Button(EditorStatics.StringArrowUp, EditorStatics.Width_20)) { int _nextIndex = _rowIndex - 1; if (tableSO.Table.ShiftRow(_rowIndex, _nextIndex)) { Debug.Log(string.Format("Shifted row up. From Index: {0}, To Index: {1}", _rowIndex, _nextIndex)); } } // Shift row to next index if (GUILayout.Button(EditorStatics.StringArrowDown, EditorStatics.Width_20)) { int _nextIndex = _rowIndex + 1; if (tableSO.Table.ShiftRow(_rowIndex, _nextIndex)) { Debug.Log(string.Format("Shifted row down. From Index: {0}, To Index: {1}", _rowIndex, _nextIndex)); } } // Display row index EditorStatics.CreateLabelField(_rowIndex.ToString(), EditorStatics.Width_50); GUIStyle _styleC = EditorStatics.GetBoxStyle(0, 0, 0, 0, 0, 0, 2, 2, 0, 26); _styleC.alignment = TextAnchor.MiddleCenter; style.wordWrap = true; int _columnCount = tableSO.Table.ColumnCount; for (int _j = 0; _j < _columnCount; _j++) { ITableRowValue _column = _row.RowColumns[_j]; EditorStatics.CreateLabelField( _column.Value.ShorterText(10, true), EditorStatics.Width_80, _styleC ); // Push the next one EditorStatics.CreateLabelField("", EditorStatics.Width_5); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } }