feat: Improved Log Settings Window Appearance (#1885)

* setting window min size

* using Layout scopes

* adding scroll bar

* setting label and field widths
This commit is contained in:
James Frowen 2020-05-12 16:34:24 +01:00 committed by GitHub
parent 5726d3b84a
commit 69b845183c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 25 deletions

View File

@ -7,8 +7,10 @@ namespace Mirror.EditorScripts.Logging
public class LogLevelWindow : EditorWindow
{
[SerializeField] LogSettings settings = null;
SerializedObject serializedObject;
SerializedProperty settingsProp;
Vector2 dictionaryScrollPosition;
void OnEnable()
{
@ -25,15 +27,22 @@ void OnEnable()
void OnGUI()
{
EditorGUILayout.BeginVertical();
using (EditorGUILayout.ScrollViewScope scrollScope = new EditorGUILayout.ScrollViewScope(dictionaryScrollPosition, GUIStyle.none, GUI.skin.verticalScrollbar))
{
dictionaryScrollPosition = scrollScope.scrollPosition;
using (new EditorGUILayout.VerticalScope())
{
using (new EditorGUILayout.VerticalScope())
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(new GUIContent("Mirror Log Levels"), EditorStyles.boldLabel);
EditorGUILayout.Space();
EditorGUILayout.Space();
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);
}
using (new EditorGUILayout.VerticalScope())
{
serializedObject.Update();
EditorGUILayout.PropertyField(settingsProp);
serializedObject.ApplyModifiedProperties();
@ -51,14 +60,16 @@ void OnGUI()
{
LogLevelsGUI.DrawLogFactoryDictionary(settings);
}
EditorGUILayout.EndVertical();
}
}
}
}
[MenuItem("Window/Analysis/Mirror Log Levels", priority = 20002)]
public static void ShowWindow()
{
LogLevelWindow window = GetWindow<LogLevelWindow>();
window.minSize = new Vector2(200, 100);
window.titleContent = new GUIContent("Mirror Log levels");
window.Show();
}

View File

@ -45,7 +45,14 @@ static void DrawLoggerField(KeyValuePair<string, ILogger> item)
ILogger logger = item.Value;
string name = item.Key;
logger.filterLogType = (LogType)EditorGUILayout.EnumPopup(new GUIContent(name), logger.filterLogType);
const float fieldWidth = 100f;
const float inspectorMargin = 25f;
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField(new GUIContent(name), GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth - fieldWidth - inspectorMargin));
logger.filterLogType = (LogType)EditorGUILayout.EnumPopup(logger.filterLogType, GUILayout.Width(fieldWidth));
}
}
}
}