Skip to content

Commit 96b9825

Browse files
committed
Merge develop
1 parent bb6ca62 commit 96b9825

File tree

18 files changed

+955
-1088
lines changed

18 files changed

+955
-1088
lines changed

com.unity.multiplayer.mlapi/Editor/NetworkObjectEditor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public override void OnInspectorGUI()
4343
{
4444
EditorGUILayout.LabelField("PrefabHashGenerator: ", m_NetworkObject.PrefabHashGenerator, EditorStyles.label);
4545
EditorGUILayout.LabelField("PrefabHash: ", m_NetworkObject.PrefabHash.ToString(), EditorStyles.label);
46-
EditorGUILayout.LabelField("InstanceId: ", m_NetworkObject.NetworkInstanceId.ToString(), EditorStyles.label);
46+
EditorGUILayout.LabelField("GlobalObjectIdHash64: ", m_NetworkObject.GlobalObjectIdHash64.ToString("X"), EditorStyles.label);
4747
EditorGUILayout.LabelField("NetworkId: ", m_NetworkObject.NetworkObjectId.ToString(), EditorStyles.label);
4848
EditorGUILayout.LabelField("OwnerId: ", m_NetworkObject.OwnerClientId.ToString(), EditorStyles.label);
4949
EditorGUILayout.LabelField("IsSpawned: ", m_NetworkObject.IsSpawned.ToString(), EditorStyles.label);
@@ -83,7 +83,7 @@ public override void OnInspectorGUI()
8383
{
8484
base.OnInspectorGUI();
8585
EditorGUILayout.LabelField("PrefabHash: ", m_NetworkObject.PrefabHash.ToString(), EditorStyles.label);
86-
EditorGUILayout.LabelField("InstanceId: ", m_NetworkObject.NetworkInstanceId.ToString(), EditorStyles.label);
86+
EditorGUILayout.LabelField("GlobalObjectIdHash64: ", m_NetworkObject.GlobalObjectIdHash64.ToString("X"), EditorStyles.label);
8787
}
8888
}
8989
}

com.unity.multiplayer.mlapi/Editor/NetworkScenePostProcessor.cs

Lines changed: 0 additions & 67 deletions
This file was deleted.

com.unity.multiplayer.mlapi/Editor/NetworkScenePostProcessor.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ internal void HandleApproval(ulong ownerClientId, bool createPlayerObject, ulong
15251525

15261526
if (observedObject.IsSceneObject == null || observedObject.IsSceneObject.Value)
15271527
{
1528-
writer.WriteUInt64Packed(observedObject.NetworkInstanceId);
1528+
writer.WriteUInt64Packed(observedObject.GlobalObjectIdHash64);
15291529
}
15301530
else
15311531
{

com.unity.multiplayer.mlapi/Runtime/Core/NetworkObject.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,20 @@ namespace MLAPI
2020
[DisallowMultipleComponent]
2121
public sealed class NetworkObject : MonoBehaviour
2222
{
23+
[HideInInspector]
24+
[SerializeField]
25+
internal ulong GlobalObjectIdHash64;
26+
27+
#if UNITY_EDITOR
2328
private void OnValidate()
2429
{
30+
var globalObjectIdString = UnityEditor.GlobalObjectId.GetGlobalObjectIdSlow(this).ToString();
31+
GlobalObjectIdHash64 = XXHash.Hash64(globalObjectIdString);
32+
2533
// Set this so the hash can be serialized on Scene objects. For prefabs, they are generated at runtime.
2634
ValidateHash();
2735
}
36+
#endif
2837

2938
internal void ValidateHash()
3039
{
@@ -77,15 +86,6 @@ internal set
7786

7887
internal ulong? OwnerClientIdInternal = null;
7988

80-
/// <summary>
81-
/// InstanceId is the id that is unique to the object and scene for a scene object when UsePrefabSync is false.
82-
/// If UsePrefabSync is true or if it's used on non scene objects, this has no effect.
83-
/// Should not be set manually
84-
/// </summary>
85-
[HideInInspector]
86-
[SerializeField]
87-
internal ulong NetworkInstanceId;
88-
8989
/// <summary>
9090
/// The Prefab unique hash. This should not be set my the user but rather changed by editing the PrefabHashGenerator.
9191
/// It has to be the same for all instances of a prefab

com.unity.multiplayer.mlapi/Runtime/SceneManagement/NetworkSceneManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ private static void OnSceneUnloadServer(Guid switchSceneGuid)
307307
}
308308
else
309309
{
310-
writer.WriteUInt64Packed(newSceneObjects[i].NetworkInstanceId);
310+
writer.WriteUInt64Packed(newSceneObjects[i].GlobalObjectIdHash64);
311311
}
312312

313313
if (NetworkManager.Singleton.NetworkConfig.EnableNetworkVariable)

com.unity.multiplayer.mlapi/Runtime/Spawning/NetworkSpawnManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ internal void WriteSpawnCallForObject(Serialization.NetworkBuffer buffer, ulong
497497

498498
if (networkObject.IsSceneObject == null || networkObject.IsSceneObject.Value)
499499
{
500-
writer.WriteUInt64Packed(networkObject.NetworkInstanceId);
500+
writer.WriteUInt64Packed(networkObject.GlobalObjectIdHash64);
501501
}
502502
else
503503
{
@@ -682,7 +682,7 @@ internal void ClientCollectSoftSyncSceneObjectSweep(NetworkObject[] networkObjec
682682
{
683683
if (networkObjects[i].IsSceneObject == null)
684684
{
685-
PendingSoftSyncObjects.Add(networkObjects[i].NetworkInstanceId, networkObjects[i]);
685+
PendingSoftSyncObjects.Add(networkObjects[i].GlobalObjectIdHash64, networkObjects[i]);
686686
}
687687
}
688688
}

0 commit comments

Comments
 (0)