Проверьте, существует ли GameObject Unity
if (GameObject.Find("Name Of GameObject") != null)
{
// GameObject exists
}
coreyhsGames
if (GameObject.Find("Name Of GameObject") != null)
{
// GameObject exists
}
TotalAmount = FindObjectsOfType<Object>().Length;
GameObject cube;
void Start() {
cube = GameObject.FindWithTag("cube"); // I like to use tag but there are alot of metos to find a object
}
void Update() {
if(cube != null) {
Destroy(cube); // if the cube exits the cube will be destoy
} else if(cube == null) {
Debug.Log("No Object"); // else if the cube doesnt exits will it say No Object
}
}
//I hope i help you this is a simple method do check if object exists