-
Notifications
You must be signed in to change notification settings - Fork 461
Experimental/singleton removal merge #495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bc9cef3
d4579ba
e6bb49e
8085b11
6c41534
35f3d20
d961ec1
aa43072
1537ab6
5498470
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| using System; | ||
| using System; | ||
| using MLAPI.Prototyping; | ||
| using UnityEditor.Animations; | ||
| using UnityEngine; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,29 @@ public class NetworkingManagerEditor : Editor | |
| private readonly List<Type> transportTypes = new List<Type>(); | ||
| private string[] transportNames = new string[] { "Select transport..." }; | ||
|
|
||
| /// <summary> | ||
| /// Helper method that gets either the server or non-server NetworkingManager in the scene, or null if not present. | ||
| /// </summary> | ||
| public static NetworkingManager GetNetworkingManager(bool isServer) | ||
| { | ||
| foreach (var manager in FindObjectsOfType<NetworkingManager>()) | ||
| { | ||
| if (manager.IsServer == isServer) | ||
| { | ||
| return manager; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the first NetworkingManager in the scene, of any type. | ||
| /// </summary> | ||
| public static NetworkingManager GetAnyNetworkingManager() | ||
| { | ||
| return FindObjectOfType<NetworkingManager>(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I get this is just editor code
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We had similar discussions over at the RFC-side in case you'd like to contribute :) |
||
| } | ||
|
|
||
| private void ReloadTransports() | ||
| { | ||
| transportTypes.Clear(); | ||
|
|
@@ -97,7 +120,7 @@ private void Init() | |
| // Base properties | ||
| dontDestroyOnLoadProperty = serializedObject.FindProperty("DontDestroy"); | ||
| runInBackgroundProperty = serializedObject.FindProperty("RunInBackground"); | ||
| logLevelProperty = serializedObject.FindProperty("LogLevel"); | ||
| logLevelProperty = serializedObject.FindProperty("LogLevelLocal"); | ||
| networkConfigProperty = serializedObject.FindProperty("NetworkConfig"); | ||
|
|
||
| // NetworkConfig properties | ||
|
|
@@ -137,7 +160,7 @@ private void CheckNullProperties() | |
| // Base properties | ||
| dontDestroyOnLoadProperty = serializedObject.FindProperty("DontDestroy"); | ||
| runInBackgroundProperty = serializedObject.FindProperty("RunInBackground"); | ||
| logLevelProperty = serializedObject.FindProperty("LogLevel"); | ||
| logLevelProperty = serializedObject.FindProperty("LogLevelLocal"); | ||
| networkConfigProperty = serializedObject.FindProperty("NetworkConfig"); | ||
|
|
||
| // NetworkConfig properties | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| using MLAPI; | ||
| using MLAPI; | ||
| using MLAPI.LagCompensation; | ||
|
|
||
| namespace UnityEditor | ||
|
|
@@ -23,7 +23,11 @@ public override void OnInspectorGUI() | |
| { | ||
| Init(); | ||
| base.OnInspectorGUI(); | ||
| if(NetworkingManager.Singleton != null && NetworkingManager.Singleton.IsServer) | ||
|
|
||
| //FIXME: Singleton Conversion, get all of them and be sure to get the server! | ||
| NetworkingManager manager = NetworkingManagerEditor.GetNetworkingManager(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I think generally in the non-singleton case I would expect the editors to show only useful data if the actual object being selected is a NetworkManager... I just don't think that picking the first thing you see if actually useful. Also FindObjectOfType doesn't guarantee order so you could call it more than once and get different objects which doesn't seem like the desired behavior either.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably the #1 unresolved issue in this addition
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I called out something similar on the RFC-side, inlining my suggestions here too:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think one way or another we'll want a central table of NMs |
||
|
|
||
| if(manager != null ) | ||
| { | ||
| EditorGUILayout.LabelField("Total points: ", trackedObject.TotalPoints.ToString(), EditorStyles.label); | ||
| EditorGUILayout.LabelField("Avg time between points: ", trackedObject.AvgTimeBetweenPointsMs.ToString() + " ms", EditorStyles.label); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I am confused by the IsServer check because from what I can tell its always false? https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi/pull/495/files#diff-641f8f5b259017aefa68498910442cb599d894ed91c96e4811d0a79b5f0151feR24
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, that's for the
NetworkedObjectEditor.csin the Editor, not at Runtime I believe, no?