Reputation: 19
I am developing a simple game.I want to stay game object stable.However,While I am running game,game objects miss suddenly.How can I fix it?
Upvotes: 1
Views: 419
Reputation: 2586
You should find out whats turning gameobjects off but you could try something like
void OnDisable() {
gameObject.SetActive(true); // Results in the error "Game Object is already being activated or deactivated
}
or
void OnDisable() {
StartCoroutine(ReEnable());
}
public IEnumerator ReEnable() {
yield return new WaitForSeconds(0.1f);
gameObject.SetActive(true);
}
Upvotes: 1