Answer the question
In order to leave comments, you need to log in
Getting an error when deleting a prefab clone from the scene?
How to fix prefab deletion error? I'm very new to Unity and GameDev, would be very grateful for any hints.
Mistake:
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);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question