Skip to content

Commit 2bbf574

Browse files
authored
fix(NetworkBehaviourInspector): Hide SyncMethod for NT (#4019)
* fix(NetworkBehaviourInspector): Hide SyncMethod for NT NetworkTransform components are locked to a certain SyncMethod * Minor refinement
1 parent 402d766 commit 2bbf574

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Assets/Mirror/Editor/NetworkBehaviourInspector.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ namespace Mirror
99
[CanEditMultipleObjects]
1010
public class NetworkBehaviourInspector : Editor
1111
{
12+
Type scriptClass;
1213
bool syncsAnything;
1314
SyncObjectCollectionsDrawer syncObjectCollectionsDrawer;
1415

1516
// does this type sync anything? otherwise we don't need to show syncInterval
16-
bool SyncsAnything(Type scriptClass)
17+
bool SyncsAnything()
1718
{
1819
// check for all SyncVar fields, they don't have to be visible
1920
foreach (FieldInfo field in InspectorHelper.GetAllFields(scriptClass, typeof(NetworkBehaviour)))
@@ -50,11 +51,11 @@ void OnEnable()
5051
// then Unity temporarily keep using this Inspector causing things to break
5152
if (!(target is NetworkBehaviour)) { return; }
5253

53-
Type scriptClass = target.GetType();
54+
scriptClass = target.GetType();
5455

5556
syncObjectCollectionsDrawer = new SyncObjectCollectionsDrawer(serializedObject.targetObject);
5657

57-
syncsAnything = SyncsAnything(scriptClass);
58+
syncsAnything = SyncsAnything();
5859
}
5960

6061
public override void OnInspectorGUI()
@@ -94,14 +95,15 @@ protected void DrawDefaultSyncSettings()
9495
if (syncDirection.enumValueIndex == (int)SyncDirection.ServerToClient)
9596
EditorGUILayout.PropertyField(serializedObject.FindProperty("syncMode"));
9697

97-
// sync method
98-
SerializedProperty syncMethod = serializedObject.FindProperty("syncMethod");
99-
EditorGUILayout.PropertyField(syncMethod);
100-
101-
// Unreliable sync method: show a warning!
102-
if (syncMethod.enumValueIndex == (int)SyncMethod.Hybrid)
98+
// sync method: Don't show for NT-based components
99+
if (!typeof(NetworkTransformBase).IsAssignableFrom(scriptClass))
103100
{
104-
EditorGUILayout.HelpBox("Beware! Hybrid is experimental!\n- Do not use this in production yet!\n- Doesn't support [SyncVars] yet!\n- You need to use OnDe/Serialize manually!", MessageType.Warning);
101+
SerializedProperty syncMethod = serializedObject.FindProperty("syncMethod");
102+
EditorGUILayout.PropertyField(syncMethod);
103+
104+
// Hybrid sync method: show a warning!
105+
if (syncMethod.enumValueIndex == (int)SyncMethod.Hybrid)
106+
EditorGUILayout.HelpBox("Beware! Hybrid is experimental!\n- Do not use this in production yet!\n- Doesn't support [SyncVars] yet!\n- You need to use OnDe/Serialize manually!", MessageType.Warning);
105107
}
106108

107109
// sync interval

0 commit comments

Comments
 (0)