@@ -12,6 +12,15 @@ namespace MLAPI.MonoBehaviours.Core
12
12
[ AddComponentMenu ( "MLAPI/NetworkedObject" , - 99 ) ]
13
13
public sealed class NetworkedObject : MonoBehaviour
14
14
{
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
+
15
24
/// <summary>
16
25
/// Gets the unique ID of this object that is synced across the network
17
26
/// </summary>
@@ -35,16 +44,9 @@ public uint OwnerClientId
35
44
}
36
45
internal uint ownerClientId = new NetId ( 0 , 0 , false , true ) . GetClientId ( ) ;
37
46
/// <summary>
38
- /// The index of the prefab used to spawn this in the spawnablePrefabs list
47
+ /// The name of the NetworkedPrefab
39
48
/// </summary>
40
- public int SpawnablePrefabIndex
41
- {
42
- get
43
- {
44
- return spawnablePrefabIndex ;
45
- }
46
- }
47
- internal int spawnablePrefabIndex ;
49
+ public string NetworkedPrefabName = string . Empty ;
48
50
/// <summary>
49
51
/// Gets if this object is a player object
50
52
/// </summary>
@@ -57,11 +59,6 @@ public bool isPlayerObject
57
59
}
58
60
internal bool _isPlayerObject = false ;
59
61
/// <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>
65
62
/// Gets if this object is part of a pool
66
63
/// </summary>
67
64
public bool isPooledObject
@@ -115,7 +112,7 @@ public bool isSpawned
115
112
}
116
113
}
117
114
internal bool _isSpawned = false ;
118
- internal bool sceneObject = false ;
115
+ internal bool ? sceneObject = null ;
119
116
120
117
private void OnDestroy ( )
121
118
{
@@ -129,7 +126,7 @@ private void OnDestroy()
129
126
public void Spawn ( )
130
127
{
131
128
if ( NetworkingManager . singleton != null )
132
- SpawnManager . OnSpawnObject ( this ) ;
129
+ SpawnManager . SpawnPrefabIndexServer ( this ) ;
133
130
}
134
131
/// <summary>
135
132
/// Spawns an object across the network with a given owner. Can only be called from server
@@ -138,7 +135,7 @@ public void Spawn()
138
135
public void SpawnWithOwnership ( uint clientId )
139
136
{
140
137
if ( NetworkingManager . singleton != null )
141
- SpawnManager . OnSpawnObject ( this , clientId ) ;
138
+ SpawnManager . SpawnPrefabIndexServer ( this , clientId ) ;
142
139
}
143
140
/// <summary>
144
141
/// Removes all ownership of an object from any client. Can only be called from server
0 commit comments