Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions com.unity.netcode.gameobjects/Editor/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Unity.Netcode.EditorTests")]
3 changes: 3 additions & 0 deletions com.unity.netcode.gameobjects/Editor/AssemblyInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -200,6 +204,10 @@ public override void OnInspectorGUI()
Initialize();
CheckNullProperties();

#if !MULTIPLAYER_TOOLS
DrawInstallMultiplayerToolsTip();
#endif

{
var iterator = serializedObject.GetIterator();

Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Comment on lines +18 to +22
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this coming up because you have MP TOOLS package installed locally?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is an intentional change, it's present in other assemblies but we didn't have any tools integration in this assembly until now.

],
"noEngineReferences": false
}
3 changes: 3 additions & 0 deletions com.unity.netcode.gameobjects/Tests/Editor/UI.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions com.unity.netcode.gameobjects/Tests/Editor/UI/UITestHelpers.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.