diff --git a/com.unity.netcode.gameobjects/Editor/AssemblyInfo.cs b/com.unity.netcode.gameobjects/Editor/AssemblyInfo.cs new file mode 100644 index 0000000000..3437d8cec2 --- /dev/null +++ b/com.unity.netcode.gameobjects/Editor/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Unity.Netcode.EditorTests")] diff --git a/com.unity.netcode.gameobjects/Editor/AssemblyInfo.cs.meta b/com.unity.netcode.gameobjects/Editor/AssemblyInfo.cs.meta new file mode 100644 index 0000000000..5b2f096009 --- /dev/null +++ b/com.unity.netcode.gameobjects/Editor/AssemblyInfo.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4b3ac10f0d62417080a83d7e17407dd3 +timeCreated: 1631656133 \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs b/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs index 670cb974fe..63342c1c8b 100644 --- a/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs +++ b/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs @@ -10,6 +10,10 @@ namespace Unity.Netcode.Editor [CanEditMultipleObjects] public class NetworkManagerEditor : UnityEditor.Editor { + internal const string InstallMultiplayerToolsTipDismissedPlayerPrefKey = "Netcode_Tip_InstallMPTools_Dismissed"; + private static GUIStyle s_CenteredWordWrappedLabelStyle; + private static GUIStyle s_HelpBoxStyle; + // Properties private SerializedProperty m_DontDestroyOnLoadProperty; private SerializedProperty m_RunInBackgroundProperty; @@ -200,6 +204,10 @@ public override void OnInspectorGUI() Initialize(); CheckNullProperties(); +#if !MULTIPLAYER_TOOLS + DrawInstallMultiplayerToolsTip(); +#endif + { var iterator = serializedObject.GetIterator(); @@ -349,5 +357,72 @@ public override void OnInspectorGUI() } } } + + private static void DrawInstallMultiplayerToolsTip() + { + const string getToolsText = "Access additional tools for multiplayer development by installing the Multiplayer Tools package in the Package Manager."; + const string openDocsButtonText = "Open Docs"; + const string dismissButtonText = "Dismiss"; + const string targetUrl = "https://docs-multiplayer.unity3d.com/docs/tutorials/goldenpath_series/goldenpath_foundation_module"; + const string infoIconName = "console.infoicon"; + + if (PlayerPrefs.GetInt(InstallMultiplayerToolsTipDismissedPlayerPrefKey, 0) != 0) + { + return; + } + + if (s_CenteredWordWrappedLabelStyle == null) + { + s_CenteredWordWrappedLabelStyle = new GUIStyle(GUI.skin.label); + s_CenteredWordWrappedLabelStyle.wordWrap = true; + s_CenteredWordWrappedLabelStyle.alignment = TextAnchor.MiddleLeft; + } + + if (s_HelpBoxStyle == null) + { + s_HelpBoxStyle = new GUIStyle(EditorStyles.helpBox); + s_HelpBoxStyle.padding = new RectOffset(10, 10, 10, 10); + } + + var openDocsButtonStyle = GUI.skin.button; + var dismissButtonStyle = EditorStyles.linkLabel; + + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.BeginHorizontal(s_HelpBoxStyle, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false), GUILayout.MaxWidth(800)); + { + GUILayout.Label(new GUIContent(EditorGUIUtility.IconContent(infoIconName)), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)); + GUILayout.Space(4); + GUILayout.Label(getToolsText, s_CenteredWordWrappedLabelStyle, GUILayout.ExpandHeight(true)); + + GUILayout.Space(4); + + GUILayout.BeginVertical(); + GUILayout.FlexibleSpace(); + if (GUILayout.Button(openDocsButtonText, openDocsButtonStyle, GUILayout.Width(90), GUILayout.Height(30))) + { + Application.OpenURL(targetUrl); + } + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); + + GUILayout.Space(4); + + GUILayout.BeginVertical(); + GUILayout.FlexibleSpace(); + if (GUILayout.Button(dismissButtonText, dismissButtonStyle, GUILayout.ExpandWidth(false))) + { + PlayerPrefs.SetInt(InstallMultiplayerToolsTipDismissedPlayerPrefKey, 1); + } + EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); + } + GUILayout.EndHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + + GUILayout.Space(10); + } } } diff --git a/com.unity.netcode.gameobjects/Editor/com.unity.netcode.editor.asmdef b/com.unity.netcode.gameobjects/Editor/com.unity.netcode.editor.asmdef index 0b617f3ec6..5a9e666dd0 100644 --- a/com.unity.netcode.gameobjects/Editor/com.unity.netcode.editor.asmdef +++ b/com.unity.netcode.gameobjects/Editor/com.unity.netcode.editor.asmdef @@ -7,5 +7,19 @@ ], "includePlatforms": [ "Editor" - ] + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [ + { + "name": "com.unity.multiplayer.tools", + "expression": "", + "define": "MULTIPLAYER_TOOLS" + } + ], + "noEngineReferences": false } \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Tests/Editor/UI.meta b/com.unity.netcode.gameobjects/Tests/Editor/UI.meta new file mode 100644 index 0000000000..f22cc756dc --- /dev/null +++ b/com.unity.netcode.gameobjects/Tests/Editor/UI.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f672293e0efc41a6a7e930fd7ff14436 +timeCreated: 1631650280 \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Tests/Editor/UI/UITestHelpers.cs b/com.unity.netcode.gameobjects/Tests/Editor/UI/UITestHelpers.cs new file mode 100644 index 0000000000..5eefc13da0 --- /dev/null +++ b/com.unity.netcode.gameobjects/Tests/Editor/UI/UITestHelpers.cs @@ -0,0 +1,15 @@ +using Unity.Netcode.Editor; +using UnityEditor; +using UnityEngine; + +namespace Unity.Netcode.EditorTests +{ + internal static class UITestHelpers + { + [MenuItem("Netcode/UI/Reset Multiplayer Tools Tip Status")] + private static void ResetMultiplayerToolsTipStatus() + { + PlayerPrefs.DeleteKey(NetworkManagerEditor.InstallMultiplayerToolsTipDismissedPlayerPrefKey); + } + } +} diff --git a/com.unity.netcode.gameobjects/Tests/Editor/UI/UITestHelpers.cs.meta b/com.unity.netcode.gameobjects/Tests/Editor/UI/UITestHelpers.cs.meta new file mode 100644 index 0000000000..c9addc4f10 --- /dev/null +++ b/com.unity.netcode.gameobjects/Tests/Editor/UI/UITestHelpers.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bde5fc3349494f77bebd0be12a6957e1 +timeCreated: 1631650292 \ No newline at end of file