mirror of
https://github.com/smyalygames/monopoly.git
synced 2025-12-29 07:48:48 +01:00
Added multiplayer plugin
This commit is contained in:
70
Assets/Mirror/Editor/Logging/LogLevelWindow.cs
Normal file
70
Assets/Mirror/Editor/Logging/LogLevelWindow.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Mirror.Logging;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.EditorScripts.Logging
|
||||
{
|
||||
public class LogLevelWindow : EditorWindow
|
||||
{
|
||||
[Header("Log Settings Asset")]
|
||||
[SerializeField] LogSettings settings = null;
|
||||
|
||||
SerializedObject serializedObject;
|
||||
SerializedProperty settingsProp;
|
||||
Vector2 dictionaryScrollPosition;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
serializedObject = new SerializedObject(this);
|
||||
settingsProp = serializedObject.FindProperty(nameof(settings));
|
||||
|
||||
LogSettings existingSettings = EditorLogSettingsLoader.FindLogSettings();
|
||||
if (existingSettings != null)
|
||||
{
|
||||
settingsProp.objectReferenceValue = existingSettings;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
using (EditorGUILayout.ScrollViewScope scrollScope = new EditorGUILayout.ScrollViewScope(dictionaryScrollPosition, GUIStyle.none, GUI.skin.verticalScrollbar))
|
||||
{
|
||||
dictionaryScrollPosition = scrollScope.scrollPosition;
|
||||
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
using (new EditorGUILayout.VerticalScope())
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(settingsProp);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
if (settings == null)
|
||||
{
|
||||
LogSettings newSettings = LogLevelsGUI.DrawCreateNewButton();
|
||||
if (newSettings != null)
|
||||
{
|
||||
settingsProp.objectReferenceValue = newSettings;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogLevelsGUI.DrawLogFactoryDictionary(settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[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();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Mirror/Editor/Logging/LogLevelWindow.cs.meta
Normal file
11
Assets/Mirror/Editor/Logging/LogLevelWindow.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3dbf48190d77d243b87962a82c3b164
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
Assets/Mirror/Editor/Logging/LogLevelsGUI.cs
Normal file
61
Assets/Mirror/Editor/Logging/LogLevelsGUI.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
using Mirror.Logging;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.EditorScripts.Logging
|
||||
{
|
||||
public static class LogLevelsGUI
|
||||
{
|
||||
public static LogSettings DrawCreateNewButton()
|
||||
{
|
||||
if (GUILayout.Button("Create New"))
|
||||
{
|
||||
return ScriptableObjectUtility.CreateAsset<LogSettings>(nameof(LogSettings));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void DrawLogFactoryDictionary(LogSettings settings)
|
||||
{
|
||||
using (EditorGUI.ChangeCheckScope scope = new EditorGUI.ChangeCheckScope())
|
||||
{
|
||||
if (LogFactory.loggers.Count == 0)
|
||||
{
|
||||
EditorGUILayout.LabelField("No Keys found in LogFactory.loggers\nPlay the game for default log values to be added to LogFactory", EditorStyles.wordWrappedLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Logging Components", EditorStyles.boldLabel);
|
||||
|
||||
foreach (KeyValuePair<string, ILogger> item in LogFactory.loggers)
|
||||
{
|
||||
DrawLoggerField(item);
|
||||
}
|
||||
|
||||
if (scope.changed)
|
||||
{
|
||||
settings.SaveFromDictionary(LogFactory.loggers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawLoggerField(KeyValuePair<string, ILogger> item)
|
||||
{
|
||||
ILogger logger = item.Value;
|
||||
string name = item.Key;
|
||||
|
||||
const float fieldWidth = 100f;
|
||||
const float inspectorMargin = 25f;
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.LabelField(new GUIContent(ObjectNames.NicifyVariableName(name)), GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth - fieldWidth - inspectorMargin));
|
||||
logger.filterLogType = (LogType)EditorGUILayout.EnumPopup(logger.filterLogType, GUILayout.Width(fieldWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Mirror/Editor/Logging/LogLevelsGUI.cs.meta
Normal file
11
Assets/Mirror/Editor/Logging/LogLevelsGUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d6ce9d62a2d2ec4d8cef8a0d22b8dd2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Mirror/Editor/Logging/LogSettingsEditor.cs
Normal file
24
Assets/Mirror/Editor/Logging/LogSettingsEditor.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Mirror.Logging;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.EditorScripts.Logging
|
||||
{
|
||||
[CustomEditor(typeof(LogSettings))]
|
||||
public class LogSettingsEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
CurrentScriptField();
|
||||
|
||||
LogLevelsGUI.DrawLogFactoryDictionary(target as LogSettings);
|
||||
}
|
||||
|
||||
public void CurrentScriptField()
|
||||
{
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"));
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Mirror/Editor/Logging/LogSettingsEditor.cs.meta
Normal file
11
Assets/Mirror/Editor/Logging/LogSettingsEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f4ecb3d81ce9ff44b91f311ee46d4ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Mirror/Editor/Logging/NetworkLogSettingsEditor.cs
Normal file
31
Assets/Mirror/Editor/Logging/NetworkLogSettingsEditor.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Mirror.Logging;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Mirror.EditorScripts.Logging
|
||||
{
|
||||
[CustomEditor(typeof(NetworkLogSettings))]
|
||||
public class NetworkLogSettingsEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
NetworkLogSettings target = this.target as NetworkLogSettings;
|
||||
|
||||
if (target.settings == null)
|
||||
{
|
||||
LogSettings newSettings = LogLevelsGUI.DrawCreateNewButton();
|
||||
if (newSettings != null)
|
||||
{
|
||||
SerializedProperty settingsProp = serializedObject.FindProperty("settings");
|
||||
settingsProp.objectReferenceValue = newSettings;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogLevelsGUI.DrawLogFactoryDictionary(target.settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37fb96d5bbf965d47acfc5c8589a1b71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user