Skip to content

Commit 21ff894

Browse files
test
Adding the test for this fix.
1 parent 2dd2918 commit 21ff894

File tree

3 files changed

+426
-1
lines changed

3 files changed

+426
-1
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/AttachableBehaviourTests.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected override void OnServerAndClientsCreated()
5555
attachableNetworkObject.SetOwnershipStatus(NetworkObject.OwnershipStatus.Transferable);
5656

5757
// The target prefab that the source prefab will attach
58-
// will be parented under the target prefab.
58+
// to will be parented under the target prefab.
5959
m_TargetNodePrefabA = CreateNetworkObjectPrefab("TargetA");
6060
m_TargetNodePrefabB = CreateNetworkObjectPrefab("TargetB");
6161
var sourceChild = new GameObject("SourceChild");
@@ -676,10 +676,13 @@ internal class TestAttachable : AttachableBehaviour
676676
public GameObject DefaultParent => m_DefaultParent;
677677
public AttachState State => m_AttachState;
678678

679+
public bool DestroyWithScene;
680+
679681
public override void OnNetworkSpawn()
680682
{
681683
AttachStateChange += OnAttachStateChangeEvent;
682684
name = $"{name}-{NetworkManager.LocalClientId}";
685+
NetworkObject.DestroyWithScene = DestroyWithScene;
683686
base.OnNetworkSpawn();
684687
}
685688

@@ -780,9 +783,16 @@ public bool CheckForState(bool checkAttached, bool checkEvent)
780783
/// </summary>
781784
internal class TestNode : AttachableNode
782785
{
786+
public bool DestroyWithScene;
783787
public bool OnAttachedInvoked { get; private set; }
784788
public bool OnDetachedInvoked { get; private set; }
785789

790+
public override void OnNetworkSpawn()
791+
{
792+
NetworkObject.DestroyWithScene = DestroyWithScene;
793+
base.OnNetworkSpawn();
794+
}
795+
786796
public bool IsAttached(AttachableBehaviour attachableBehaviour)
787797
{
788798
return m_AttachedBehaviours.Contains(attachableBehaviour);

0 commit comments

Comments
 (0)