Files
AppleHillsProduction/Assets/Scripts/DamianExperiments/Destroyer.cs

26 lines
550 B
C#

using UnityEngine;
public class Destroyer : MonoBehaviour
{
[SerializeField]
private GameObject targetToDestroy;
// Destroy the GameObject this component is attached to
public void DestroySelf()
{
Destroy(gameObject);
}
// Destroy the GameObject assigned in the inspector
public void DestroyTarget()
{
if (targetToDestroy == null)
{
Debug.LogWarning("Destroyer: No target assigned to destroy.", this);
return;
}
Destroy(targetToDestroy);
}
}