Answer the question
In order to leave comments, you need to log in
Why is the object not destroyed?
Why is the object not deleted, I need an object from the array to be created, and another one to be deleted, so that there is always only 1 object from the array of prefabs on the stage
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BuyMobs : MonoBehaviour
{
public GameObject[] Mobs;
public GameObject Canvas;
public int MobsNomer;
private GameObject cyrGameObject;
public void OnMouseDown()
{
if (cyrGameObject != null) Destroy(cyrGameObject);
cyrGameObject = Instantiate(Mobs[MobsNomer], new Vector3(125, 310, 0), Quaternion.identity);
cyrGameObject.transform.SetParent(Canvas.transform);
}
}
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