Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ public class NetworkObjectEditor : UnityEditor.Editor

#if UNIFIED_NETCODE
/// <summary>
/// Register for the GhostAdapter removal event.
/// Register for the GhostObject removal event.
/// </summary>
[InitializeOnLoadMethod]
private static void OnApplicationStart()
{
GhostAdapterEditor.OnGhostAdapterPreRemoval = OnGhostAdapterPreRemoval;
GhostObjectEditor.OnGhostObjectPreRemoval = OnGhostObjectPreRemoval;
}

/// <summary>
/// Callback to remove the GhostBehaviours prior to removing GhostAdapter.
/// Callback to remove the GhostBehaviours prior to removing GhostObject.
/// </summary>
/// <param name="gameObject">The <see cref="GameObject"/> with the <see cref="GhostAdapter"/> component being removed.</param>
private static void OnGhostAdapterPreRemoval(GameObject gameObject)
/// <param name="gameObject">The <see cref="GameObject"/> with the <see cref="GhostObject"/> component being removed.</param>
private static void OnGhostObjectPreRemoval(GameObject gameObject)
{
var ghostBehaviours = gameObject.GetComponentsInChildren<GhostBehaviour>();
for (int i = ghostBehaviours.Length - 1; i >= 0; i--)
{
DestroyImmediate(ghostBehaviours[i], true);
}
var networkObject = gameObject.GetComponent<NetworkObject>();
networkObject.GhostAdapter = null;
networkObject.GhostObject = null;
networkObject.HasGhost = false;
networkObject.HadBridge = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ namespace Unity.Netcode
/// specific to the N4E-spawned hybrid prefab instance that has the matching <see cref="NetworkObjectId"/>.
/// </summary>

[DefaultExecutionOrder(GhostAdapterExecutionOrder.ExecutionOrder + 1)]
[DefaultExecutionOrder(GhostObjectExecutionOrder.ExecutionOrder + 1)]
//BREAK --- Fix this on UNIFIED side 1st
public partial class NetworkObjectBridge : GhostBehaviour
{
// DefaultExecutionOrder
// TODO: Define a const for the value used on GhostAdapter and use that value
// to set the execution order so if it changes on GhostAdapter it updates here.
// TODO: Define a const for the value used on GhostObject and use that value
// to set the execution order so if it changes on GhostObject it updates here.
#if UNITY_EDITOR
private void OnValidate()
{
hideFlags = HideFlags.HideInInspector;

var ghostAdapter = GetComponent<GhostAdapter>();
var ghostAdapter = GetComponent<GhostObject>();
if (ghostAdapter == null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class NetworkClient
/// <summary>
/// The ClientId of the NetworkClient
/// </summary>
public ulong ClientId;
public ulong ClientId { get; internal set; }

/// <summary>
/// The PlayerObject of the Client
Expand Down
22 changes: 11 additions & 11 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private void CheckForInScenePlaced()
#if UNIFIED_NETCODE
[HideInInspector]
[SerializeField]
internal GhostAdapter GhostAdapter;
internal GhostObject GhostObject;

[HideInInspector]
[SerializeField]
Expand All @@ -388,16 +388,16 @@ private void OnApplicationUpdate()
internal void UnifiedValidation()
{
NetworkObjectBridge = GetComponent<NetworkObjectBridge>();
GhostAdapter = GetComponent<GhostAdapter>();
GhostObject = GetComponent<GhostObject>();

HasGhost = GhostAdapter != null;
HasGhost = GhostObject != null;
if (HasGhost)
{
//TODO: Needs to be validated once develop-2.0.0 is merged.
if (InScenePlaced)
{
Debug.LogError($"This experimental version of NGO does not support hybrid in-scene placed objects.");
Destroy(GhostAdapter);
Destroy(GhostObject);
HasGhost = false;
return;
}
Expand All @@ -420,7 +420,7 @@ public void ApplyScale(Vector3 scale)
{
if (HasGhost)
{
GhostAdapter.ApplyPostTransformMatrixScale(scale);
GhostObject.ApplyPostTransformMatrixScale(scale);
}
}
#endif
Expand Down Expand Up @@ -3043,7 +3043,7 @@ internal bool InitializeChildNetworkBehaviours()
{
#if COM_UNITY_MODULES_PHYSICS || COM_UNITY_MODULES_PHYSICS2D
// TODO-UNIFIED: This needs to be updated to make it "opt-in".
// If the GhostAdapter is not configured for prediction but is still using a Rigidbody, then go ahead and remove it on
// If the GhostObject is not configured for prediction but is still using a Rigidbody, then go ahead and remove it on
// the client side to improve performance by default.
// TODO-UNIFIED: Determine if recent unified physics updates does not require checking for prediction.
if (NetworkRigidbodies != null)
Expand Down Expand Up @@ -3084,8 +3084,8 @@ internal bool InitializeChildNetworkBehaviours()
#if UNIFIED_NETCODE_DESTROY
// When hybrid spawning, the transform is synchronized by the GhostObject.
// As a convenience, we remove and destroy all NetworkTransforms.
// TODO-Parenting-Related-Area: We need to replicate this functionality in a GhostAdapter
// Possibly use a "Synchronize" property and display only on children of a root parent GhostAdapter.
// TODO-Parenting-Related-Area: We need to replicate this functionality in a GhostObject
// Possibly use a "Synchronize" property and display only on children of a root parent GhostObject.
if (NetworkTransforms != null)
{
NetworkManager.Log.Warning(new Logging.Context(LogLevel.Developer, $"[]{name} Hybrid spawned objects do not support {nameof(NetworkTransform)} and " +
Expand Down Expand Up @@ -3896,7 +3896,7 @@ private void OnDisable()
Debug.Log("Disabled!");
if (IsSpawned || HasGhost)
{
if (HasGhost && GhostAdapter.IsPrefab())
if (HasGhost && GhostObject.IsPrefab())
{
return;
}
Expand Down Expand Up @@ -3933,7 +3933,7 @@ private void InitGhost()
return;
}

if (!HasGhost || !NetworkObjectBridge || GhostAdapter.IsPrefab())
if (!HasGhost || !NetworkObjectBridge || GhostObject.IsPrefab())
{
// Nothing to register
return;
Expand All @@ -3944,7 +3944,7 @@ private void InitGhost()
{
Debug.Log($"[{nameof(NetworkObject)}] GhostBridge {name} detected and instantiated.");
}
if (GhostAdapter.WasInitialized && NetworkObjectBridge.NetworkObjectId.Value != 0)
if (GhostObject.WasInitialized && NetworkObjectBridge.NetworkObjectId.Value != 0)
{
NetworkManager.SpawnManager.GhostSpawnManager.RegisterGhostBridge(NetworkObjectBridge.NetworkObjectId.Value, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void Handle(ref NetworkContext context)
#if UNIFIED_NETCODE
if (networkObject.HasGhost)
{
// Handles the GhostAdapter side of things for parenting
// Handles the GhostObject side of things for parenting
networkObject.NetworkObjectBridge.HybridParentUpdate(Scale);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2781,7 +2781,7 @@ internal void PopulateScenePlacedObjects(Scene sceneToFilterBy, bool clearSceneP

// We check to make sure the NetworkManager instance is the same one to be "NetcodeIntegrationTestHelpers" compatible and filter the list on a per-scene basis (for additive scenes)
#if UNIFIED_NETCODE
// TODO: When we solve for GhostAdapter in-scene placed.
// TODO: When we solve for GhostObject in-scene placed.
if (!networkObjectInstance.HasGhost && networkObjectInstance.NetworkManagerOwner == NetworkManager && networkObjectInstance.isActiveAndEnabled)
#else
if (networkObjectInstance.NetworkManagerOwner == NetworkManager && networkObjectInstance.isActiveAndEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ public IEnumerator SetUp()
#if UNIFIED_NETCODE
private void RegisterPendingGhost(NetworkObject networkObject, ulong networkObjectId)
{
var ghost = networkObject.GetComponent<GhostAdapter>();
Assert.IsNotNull(ghost, $"[RegisterPendingGhost][NetworkObject-{networkObjectId}] Has no {nameof(GhostAdapter)}!");
var ghost = networkObject.GetComponent<GhostObject>();
Assert.IsNotNull(ghost, $"[RegisterPendingGhost][NetworkObject-{networkObjectId}] Has no {nameof(GhostObject)}!");
foreach (var networkManager in m_NetworkManagers)
{
// If the world matches, then register the instance with this NetworkManager's spawn manager.
Expand Down Expand Up @@ -1837,9 +1837,9 @@ protected void DestroySceneNetworkObjects()
{
#if UNIFIED_NETCODE
// Handle removing the prefab reference and destroying it
// and then destroying the ghostAdapter prior to destroying
// and then destroying the GhostObject prior to destroying
// a hybrid prefab.
var ghostAdapter = networkObject.GetComponent<GhostAdapter>();
var ghostAdapter = networkObject.GetComponent<GhostObject>();
if (ghostAdapter != null)
{
if (ghostAdapter.prefabReference != null)
Expand Down Expand Up @@ -2423,10 +2423,10 @@ protected GameObject CreateHybridPrefab(string baseName, bool moveToDDOL = true)

// When adding a Hybrid/Ghost prefab:
// - We disabled the GameObject prior to adding the GhostPrefabReference (so IsPrefab() == true).
// - Add the GhostAdapter and GhostPrefabReference
// - Add the GhostObject and GhostPrefabReference
// - Then set it back to active.
gameObject.SetActive(false);
var adapter = gameObject.AddComponent<GhostAdapter>();
var adapter = gameObject.AddComponent<GhostObject>();
// Mark the reference as post processing to avoid registering this instance automatically.
GhostPrefabReference.s_IsPostProcessing = true;
adapter.prefabReference = ScriptableObject.CreateInstance<GhostPrefabReference>();
Expand All @@ -2443,7 +2443,7 @@ protected GameObject CreateHybridPrefab(string baseName, bool moveToDDOL = true)
// with the dependency to prediction manual test).
adapter.SupportedGhostModes = GhostModeMask.Interpolated;

// Once done with setting up the GhostAdapter, we can set it back to active in the hierarchy
// Once done with setting up the GhostObject, we can set it back to active in the hierarchy
gameObject.SetActive(true);

// GhostBehaviours that are part of a prefab will not invoke Ghost.InternalAcquireEntityReference
Expand All @@ -2455,12 +2455,12 @@ protected GameObject CreateHybridPrefab(string baseName, bool moveToDDOL = true)

// NetworkObject Ghost specific settings
no.HasGhost = true;
no.GhostAdapter = adapter;
no.GhostObject = adapter;
no.HadBridge = true;
no.NetworkObjectBridge = bridge;

// Disable transform synchronization for NetworkObject serialization
// since that is handled by the GhostAdapter.
// since that is handled by the GhostObject.
no.SynchronizeTransform = false;

// Turn it into a test prefab
Expand Down