Skip to content

Commit 335eb73

Browse files
committed
corrected accessibility for NetworkObjectEditor
1 parent 0d20070 commit 335eb73

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

com.unity.netcode.gameobjects/Editor/NetworkObjectEditor.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ private static void OnApplicationStart()
4242
/// <param name="gameObject">The <see cref="GameObject"/> with the <see cref="GhostObject"/> component being removed.</param>
4343
private static void OnGhostObjectPreRemoval(GameObject gameObject)
4444
{
45-
var ghostBehaviours = gameObject.GetComponentsInChildren<GhostBehaviour>();
46-
for (int i = ghostBehaviours.Length - 1; i >= 0; i--)
45+
// GhostBehaviour is internal to N4E and its IVT grant to this assembly differs between N4E's editor-bundled and standalone builds, so resolve it via reflection to stay build-agnostic.
46+
var ghostBehaviourType = typeof(NetcodeWorld).Assembly.GetType("Unity.Netcode.GhostBehaviour");
47+
if (ghostBehaviourType != null)
4748
{
48-
DestroyImmediate(ghostBehaviours[i], true);
49+
var ghostBehaviours = gameObject.GetComponentsInChildren(ghostBehaviourType);
50+
for (int i = ghostBehaviours.Length - 1; i >= 0; i--)
51+
{
52+
DestroyImmediate(ghostBehaviours[i], true);
53+
}
4954
}
5055
var networkObject = gameObject.GetComponent<NetworkObject>();
5156
networkObject.GhostObject = null;

0 commit comments

Comments
 (0)