Как исправить ошибку с удалением префаба? Я совсем недавно пришёл в Unity и GameDev, был-бы очень благодарен за любые подсказки.
Ошибка:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ClickHelper : MonoBehaviour {
public GameObject obj;
public void OnCLick()
{
Instantiate(obj);
Destroy(obj);
}
}