mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
feature: NetworkBehaviour: HasSyncObjects for NetworkBehaviourInspector to avoid Reflection
This commit is contained in:
parent
7c28f06c8f
commit
f1b8aa4fc2
@ -40,10 +40,7 @@ bool SyncsAnything(Type scriptClass)
|
||||
// search for SyncObjects manually.
|
||||
// Any SyncObject should be added to syncObjects when unity creates an
|
||||
// object so we can check length of list so see if sync objects exists
|
||||
FieldInfo syncObjectsField = scriptClass.GetField("syncObjects", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
List<SyncObject> syncObjects = (List<SyncObject>)syncObjectsField.GetValue(serializedObject.targetObject);
|
||||
|
||||
return syncObjects.Count > 0;
|
||||
return ((NetworkBehaviour)serializedObject.targetObject).HasSyncObjects();
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
|
@ -58,6 +58,7 @@ public abstract class NetworkBehaviour : MonoBehaviour
|
||||
|
||||
// SyncLists, SyncSets, etc.
|
||||
protected readonly List<SyncObject> syncObjects = new List<SyncObject>();
|
||||
public bool HasSyncObjects() => syncObjects.Count > 0;
|
||||
|
||||
// NetworkIdentity based values set from NetworkIdentity.Awake(),
|
||||
// which is way more simple and way faster than trying to figure out
|
||||
|
Loading…
Reference in New Issue
Block a user