/
DestroyObject (Unity)

DestroyObject (Unity)

- Declaration

public static void DestroyObject(this CavrnusSpaceConnection spaceConn, CavrnusSpawnedObject spawnedObject)

- Description

Destroys the given object.

The best way to access an object that can be destroyed is to search for the CavrnusSpawnedObjectFlag on a GameObject. This will indicate that the object was spawned via a call to SpawnObject.

You can only destroy an instance that was created via SpawnedObject. If you want to get rid of something that was built-into the scene try changing its "Visibility" Bool Property, use either a No-Code Component or with a PostBoolPropertyUpdate.

- Sample

using CavrnusSdk.API; using CavrnusSdk; using UnityEngine; public class DestroyObject : MonoBehaviour { public void DestroyMe() { if (GetComponent<CavrnusSpawnedObjectFlag>() == null) Debug.LogError("This object was not spawned via Cavrnus, cannot destroy it"); CavrnusSpawnedObject spawnedObject = GetComponent<CavrnusSpawnedObjectFlag>().SpawnedObject; spawnedObject.DestroyObject(); } }

Related content

SpawnObject (Unity)
SpawnObject (Unity)
Read with this
DestroyObject (.NET)
DestroyObject (.NET)
More like this
DestroyObject (Unreal Engine)
DestroyObject (Unreal Engine)
More like this
ExitSpace
More like this
CavrnusSpawnedObject (Unity)
CavrnusSpawnedObject (Unity)
More like this
ExitSpace (Unreal Engine)
ExitSpace (Unreal Engine)
More like this