22 lines
531 B
C#
22 lines
531 B
C#
using UnityEngine;
|
|
|
|
public class DestroyMe : MonoBehaviour
|
|
{
|
|
[SerializeField] private float timeToDestroy;
|
|
[SerializeField] private GameObject prefab;
|
|
[SerializeField] private Transform overridePrefabPosition;
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (!prefab) return;
|
|
var t = transform;
|
|
if (overridePrefabPosition) t = overridePrefabPosition;
|
|
Instantiate(prefab, t.position, Quaternion.identity);
|
|
}
|
|
|
|
public void Process()
|
|
{
|
|
Destroy(gameObject, timeToDestroy);
|
|
}
|
|
}
|