Skip to content

Commit 453c8e2

Browse files
update
Resolving merge issues.
1 parent ab1addf commit 453c8e2

8 files changed

Lines changed: 30 additions & 37 deletions

File tree

com.unity.netcode.gameobjects/Editor/Configuration/NetcodeForGameObjectsProjectSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using UnityEditor;
22
using UnityEngine;
33

4-
namespace Unity.Netcode.Editor.Configuration
4+
namespace Unity.Netcode.GameObjects.Editor.Configuration
55
{
66
/// <summary>
77
/// A <see cref="ScriptableSingleton{T}"/> of type <see cref="NetcodeForGameObjectsProjectSettings"/>.

com.unity.netcode.gameobjects/Editor/Configuration/NetcodeSettingsProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22
using System.IO;
3-
using Unity.Netcode.Editor.Configuration;
43
using UnityEditor;
54
using UnityEngine;
65
using Directory = UnityEngine.Windows.Directory;

com.unity.netcode.gameobjects/Editor/Configuration/NetworkPrefabProcessor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Generic;
2-
using Unity.Netcode.Editor.Configuration;
32
using UnityEditor;
43
using UnityEngine;
54

com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviourUpdater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ internal void ResetDirtyObject(NetworkObject dirtyObj, bool forceSend)
115115
{
116116
foreach (var behaviour in dirtyObj.ChildNetworkBehaviours.Values)
117117
{
118-
behaviour.Value.PostNetworkVariableWrite(forceSend);
118+
behaviour.PostNetworkVariableWrite(forceSend);
119119
}
120120
}
121121

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ public void Despawn(bool destroy = true)
20872087

20882088
foreach (var behavior in ChildNetworkBehaviours.Values)
20892089
{
2090-
behavior.Value.MarkVariablesDirty(false);
2090+
behavior.MarkVariablesDirty(false);
20912091
}
20922092
NetworkManagerOwner.SpawnManager.DespawnObject(this, destroy);
20932093
}
@@ -2216,7 +2216,7 @@ internal void InvokeSessionOwnerPromoted(bool isSessionOwner)
22162216

22172217
foreach (var childBehaviour in ChildNetworkBehaviours.Values)
22182218
{
2219-
childBehaviour.Value.IsSessionOwner = isSessionOwner;
2219+
childBehaviour.IsSessionOwner = isSessionOwner;
22202220
}
22212221
}
22222222

@@ -2228,7 +2228,6 @@ internal void InvokeBehaviourOnNetworkObjectParentChanged(NetworkObject parentNe
22282228
}
22292229
foreach (var child in ChildNetworkBehaviours.Values)
22302230
{
2231-
var behaviour = childBehaviour.Value;
22322231
// Any NetworkBehaviour that is not spawned and the associated GameObject is disabled should be
22332232
// skipped over (i.e. not supported).
22342233
if (!child.IsSpawned && !child.gameObject.activeInHierarchy)
@@ -2712,30 +2711,29 @@ internal void InvokeBehaviourNetworkSpawn()
27122711
// - invocation of RPCs will work properly (and not throw exception under certain scenarios)
27132712
foreach (var childBehaviour in ChildNetworkBehaviours.Values)
27142713
{
2715-
if (!childBehaviour.Value.gameObject.activeInHierarchy)
2714+
if (!childBehaviour.gameObject.activeInHierarchy)
27162715
{
27172716
if (NetworkManagerOwner.LogLevel <= LogLevel.Developer)
27182717
{
2719-
NetworkLog.LogWarning($"{GenerateDisabledNetworkBehaviourWarning(childBehaviour.Value)}");
2718+
NetworkLog.LogWarning($"{GenerateDisabledNetworkBehaviourWarning(childBehaviour)}");
27202719
}
27212720
continue;
27222721
}
2723-
childBehaviour.Value.InternalOnNetworkSpawn();
2722+
childBehaviour.InternalOnNetworkSpawn();
27242723
}
27252724

2726-
// After initialization, we can then invoke OnNetworkSpawn on each child NetworkBehaviour.
2725+
// After internally spawning, we can then invoke OnNetworkSpawn on each child NetworkBehaviour.
27272726
foreach (var childBehaviour in ChildNetworkBehaviours.Values)
27282727
{
2729-
var behaviour = childBehaviour.Value;
2730-
if (!behaviour.gameObject.activeInHierarchy)
2728+
if (!childBehaviour.gameObject.activeInHierarchy)
27312729
{
27322730
if (NetworkManager.LogLevel <= LogLevel.Normal)
27332731
{
27342732
NetworkLog.LogWarning($"{GenerateDisabledNetworkBehaviourWarning(childBehaviour)}");
27352733
}
27362734
continue;
27372735
}
2738-
behaviour.NetworkSpawn();
2736+
childBehaviour.NetworkSpawn();
27392737
}
27402738
}
27412739

@@ -2870,7 +2868,7 @@ internal bool InitializeChildNetworkBehaviours()
28702868
{
28712869
for (int i = NetworkRigidbodies.Count - 1; i >= 0; i--)
28722870
{
2873-
m_ChildNetworkBehaviours.Remove(NetworkRigidbodies[i].NetworkBehaviourId);
2871+
ChildNetworkBehaviours.Remove(NetworkRigidbodies[i].NetworkBehaviourId);
28742872
Destroy(NetworkRigidbodies[i]);
28752873
}
28762874
NetworkRigidbodies.Clear();
@@ -2882,7 +2880,7 @@ internal bool InitializeChildNetworkBehaviours()
28822880
{
28832881
for (int i = NetworkTransforms.Count - 1; i >= 0; i--)
28842882
{
2885-
m_ChildNetworkBehaviours.Remove(NetworkTransforms[i].NetworkBehaviourId);
2883+
ChildNetworkBehaviours.Remove(NetworkTransforms[i].NetworkBehaviourId);
28862884
Destroy(NetworkTransforms[i]);
28872885
}
28882886
NetworkTransforms.Clear();
@@ -2892,7 +2890,7 @@ internal bool InitializeChildNetworkBehaviours()
28922890
return true;
28932891
}
28942892

2895-
#if UNIFIED_NETCODE
2893+
#if UNIFIED_NETCODE
28962894
private void InitializeComponentMarkers(NetworkManager networkManager)
28972895
{
28982896
// TODO: Determine if this would be useful
@@ -2945,7 +2943,7 @@ private void InitializeComponentMarkers(NetworkManager networkManager)
29452943
{
29462944
for (int i = NetworkRigidbodies.Count - 1; i >= 0; i--)
29472945
{
2948-
m_ChildNetworkBehaviours.Remove(NetworkRigidbodies[i].NetworkBehaviourId);
2946+
ChildNetworkBehaviours.Remove(NetworkRigidbodies[i].NetworkBehaviourId);
29492947
Destroy(NetworkRigidbodies[i]);
29502948
}
29512949
NetworkRigidbodies.Clear();
@@ -3476,7 +3474,7 @@ internal void SynchronizeNetworkBehaviours<T>(ref BufferSerializer<T> serializer
34763474
var synchronizationCount = (byte)0;
34773475
foreach (var childBehaviour in ChildNetworkBehaviours.Values)
34783476
{
3479-
if (childBehaviour.Value.Synchronize(ref serializer, targetClientId))
3477+
if (childBehaviour.Synchronize(ref serializer, targetClientId))
34803478
{
34813479
synchronizationCount++;
34823480
}
@@ -3497,8 +3495,8 @@ internal void SynchronizeNetworkBehaviours<T>(ref BufferSerializer<T> serializer
34973495
// Apply the network variable synchronization data
34983496
foreach (var behaviour in ChildNetworkBehaviours.Values)
34993497
{
3500-
behaviour.Value.InitializeVariables();
3501-
behaviour.Value.SetNetworkVariableData(reader, targetClientId);
3498+
behaviour.InitializeVariables();
3499+
behaviour.SetNetworkVariableData(reader, targetClientId);
35023500
}
35033501

35043502
// Read the number of NetworkBehaviours to synchronize

com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal void RegisterGhostPendingSpawn(NetworkObject networkObject, ulong netwo
7373
// them into the currently active scene upon spawn.
7474
if (!NetworkManager.IsConnectedClient && !GhostsPendingSynchronization.ContainsKey(networkObjectId))
7575
{
76-
UnityEngine.Object.DontDestroyOnLoad(networkObject.gameObject);
76+
Object.DontDestroyOnLoad(networkObject.gameObject);
7777
}
7878
else // There is matching spawn data for this pending Ghost, process the pending spawn for this hybrid instance.
7979
{
@@ -98,7 +98,7 @@ internal NetworkObject GetGhostNetworkObjectForSpawn(ulong networkObjectId)
9898
return null;
9999
}
100100
var networkObject = GhostsPendingSpawn[networkObjectId];
101-
101+
102102
GhostsPendingSpawn.Remove(networkObjectId);
103103
if (networkObject != null)
104104
{
@@ -1138,17 +1138,14 @@ internal NetworkObject CreateLocalNetworkObject(NetworkObject.SerializedObject s
11381138
networkObject = GetGhostNetworkObjectForSpawn(serializedObject.NetworkObjectId);
11391139
if (networkObject == null)
11401140
{
1141-
if (NetworkLog.CurrentLogLevel <= LogLevel.Error)
1142-
{
1143-
NetworkLog.LogError($"{nameof(NetworkPrefab)} hash was not found! In-Scene placed {nameof(NetworkObject)} soft synchronization failure for Hash: {globalObjectIdHash}!");
1144-
}
1145-
1146-
return null;
1141+
throw new Exception($"Failed to get spawned Ghost object!");
11471142
}
1148-
1149-
// Since this NetworkObject is an in-scene placed NetworkObject, if it is disabled then enable it so
1150-
// NetworkBehaviours will have their OnNetworkSpawn method invoked
1151-
if (!networkObject.gameObject.activeInHierarchy)
1143+
}
1144+
else
1145+
#endif
1146+
{
1147+
// If scene management is disabled or the NetworkObject was dynamically spawned
1148+
if (!NetworkManager.NetworkConfig.EnableSceneManagement || !serializedObject.IsSceneObject)
11521149
{
11531150
networkObject = GetNetworkObjectToSpawn(serializedObject.Hash, serializedObject.OwnerClientId, position, rotation, serializedObject.IsSceneObject, instantiationData);
11541151
}
@@ -1161,17 +1158,18 @@ internal NetworkObject CreateLocalNetworkObject(NetworkObject.SerializedObject s
11611158
{
11621159
NetworkLog.LogError($"{nameof(NetworkPrefab)} hash was not found! In-Scene placed {nameof(NetworkObject)} soft synchronization failure for Hash: {globalObjectIdHash}!");
11631160
}
1161+
1162+
return null;
11641163
}
11651164

11661165
// Since this NetworkObject is an in-scene placed NetworkObject, if it is disabled then enable it so
11671166
// NetworkBehaviours will have their OnNetworkSpawn method invoked
1168-
if (networkObject != null && !networkObject.gameObject.activeInHierarchy)
1167+
if (!networkObject.gameObject.activeInHierarchy)
11691168
{
11701169
networkObject.gameObject.SetActive(true);
11711170
}
11721171
}
11731172
}
1174-
11751173
if (networkObject == null)
11761174
{
11771175
return null;

com.unity.netcode.gameobjects/Runtime/Timing/AnticipationSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void ProcessReanticipation()
6969
{
7070
foreach (var behaviour in item.OwnerObject.ChildNetworkBehaviours.Values)
7171
{
72-
behaviour.Value.OnReanticipate(lastRoundTripTime);
72+
behaviour.OnReanticipate(lastRoundTripTime);
7373
}
7474
item.ResetAnticipation();
7575
}

com.unity.netcode.gameobjects/Tests/Editor/NetworkPrefabProcessorTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using NUnit.Framework;
2-
using Unity.Netcode.Editor.Configuration;
32
using Unity.Netcode.GameObjects.Editor.Configuration;
43
using UnityEditor;
54
using UnityEngine;

0 commit comments

Comments
 (0)