@@ -12,6 +12,15 @@ namespace MLAPI.MonoBehaviours.Core
1212 [ AddComponentMenu ( "MLAPI/NetworkedObject" , - 99 ) ]
1313 public sealed class NetworkedObject : MonoBehaviour
1414 {
15+ private void OnValidate ( )
16+ {
17+ if ( string . IsNullOrEmpty ( NetworkedPrefabName ) )
18+ {
19+ Debug . LogWarning ( "MLAPI: The networked object " + gameObject . name + " has not been assigned a networkedPrefabName. Setting it to " + gameObject . name ) ;
20+ NetworkedPrefabName = gameObject . name ;
21+ }
22+ }
23+
1524 /// <summary>
1625 /// Gets the unique ID of this object that is synced across the network
1726 /// </summary>
@@ -35,16 +44,9 @@ public uint OwnerClientId
3544 }
3645 internal uint ownerClientId = new NetId ( 0 , 0 , false , true ) . GetClientId ( ) ;
3746 /// <summary>
38- /// The index of the prefab used to spawn this in the spawnablePrefabs list
47+ /// The name of the NetworkedPrefab
3948 /// </summary>
40- public int SpawnablePrefabIndex
41- {
42- get
43- {
44- return spawnablePrefabIndex ;
45- }
46- }
47- internal int spawnablePrefabIndex ;
49+ public string NetworkedPrefabName = string . Empty ;
4850 /// <summary>
4951 /// Gets if this object is a player object
5052 /// </summary>
@@ -57,11 +59,6 @@ public bool isPlayerObject
5759 }
5860 internal bool _isPlayerObject = false ;
5961 /// <summary>
60- /// Gets or sets if this object should be replicated across the network. Can only be changed before the object is spawned
61- /// </summary>
62- [ SerializeField ]
63- public bool ServerOnly = false ;
64- /// <summary>
6562 /// Gets if this object is part of a pool
6663 /// </summary>
6764 public bool isPooledObject
@@ -115,7 +112,7 @@ public bool isSpawned
115112 }
116113 }
117114 internal bool _isSpawned = false ;
118- internal bool sceneObject = false ;
115+ internal bool ? sceneObject = null ;
119116
120117 private void OnDestroy ( )
121118 {
@@ -129,7 +126,7 @@ private void OnDestroy()
129126 public void Spawn ( )
130127 {
131128 if ( NetworkingManager . singleton != null )
132- SpawnManager . OnSpawnObject ( this ) ;
129+ SpawnManager . SpawnPrefabIndexServer ( this ) ;
133130 }
134131 /// <summary>
135132 /// Spawns an object across the network with a given owner. Can only be called from server
@@ -138,7 +135,7 @@ public void Spawn()
138135 public void SpawnWithOwnership ( uint clientId )
139136 {
140137 if ( NetworkingManager . singleton != null )
141- SpawnManager . OnSpawnObject ( this , clientId ) ;
138+ SpawnManager . SpawnPrefabIndexServer ( this , clientId ) ;
142139 }
143140 /// <summary>
144141 /// Removes all ownership of an object from any client. Can only be called from server
0 commit comments