Quiero encontrar el GameObject que está en la jerarquía correctamente en la jerarquía. Pero esto no sucede correctamente, así que quiero que 'si' funcione cuando el objeto de juego que he etiquetado esté activo, pero 'si' funciona aunque no haya otra etiqueta de objeto de juego, por lo que se produce este problema.
Nota: Mi nivel de inglés no es bueno, trato de explicarte el problema lo más que puedo, por favor dime si hay algo que no entiendes, trataré de explicarlo en detalle lo más que pueda. Gracias por su comprensión.
void Update() { if (cubes.instance.objPool.Count == 1) //It works when the number of gameobject in the list is 1 when I do a random deletion. { RewardSystem(); } } public void RewardSystem() { GameObject FoundCube = GameObject.FindGameObjectWithTag(cube_Tag_Number); if (FoundCube == null) { SoundManager.instance.GameOverMenuSound(); game_Over_Menu.SetActive(true); next_Level_Menu.SetActive(false); confetti.Stop(); clickButton.gameObject.SetActive(false); missionButton.gameObject.SetActive(false); enabled = false; } if (FoundCube != null)// problematic if { if (FoundCube.activeInHierarchy == true) // problematic if { SoundManager.instance.NextLevelMenuSound(); next_Level_Menu.SetActive(true); confetti.Play(); game_Over_Menu.SetActive(false); clickButton.gameObject.SetActive(false); missionButton.gameObject.SetActive(false); enabled = false; } } } public class cubes : MonoBehaviour { public static cubes instance; public int randomRangeNumber1, randomRangeNumber2; public List<GameObject> objPool = new List<GameObject>(); private void Awake() { if (instance == null) { instance = this; } else if (instance != null) { Destroy(gameObject); } } public void ButtonOnDown() { SoundManager.instance.LuckButtonSound(); for (int i = 0; i < 1; i++) { int index = Random.Range(randomRangeNumber1, randomRangeNumber2); GameObject.Destroy(objPool[index]); objPool.RemoveAt(index); randomRangeNumber2 = objPool.Count; } } }