- Home /
Script has been enabled during the gameplay, but never called.
I have a script attached to an empty gameobject. Basicly it is disabled, because I want that to be enabled at a certain point in the game. I tried to simply enable it with the GetComponent, and it was succesful (i saw it in the inspector), but the script, and the functions in it are never called. I also tried to instatiate the gameobject , but the same happened. Has anyone any idea why its not working?
You need to be specific about what you expect when you activate the game object. Can you post the script?
Here is the script I used for enable the other, attached to the gameobject. And it works, cos when I test the game, I can see in the inspector, that the script is enabled exactly when I want. However, the script is not calling its functions anymore. But if the script is enabled originally(before I play), it works properly. So it goes wrong just if I enable it while Im playing.
using UnityEngine; using System.Collections;
public class Switch : $$anonymous$$onoBehaviour {
void Start()
{
GetComponent<RespawnBunny>().enabled = false;
}
void Update()
{
if(Network$$anonymous$$anager2.referenceB)
{
GetComponent<RespawnBunny>().enabled = true;
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613154626im_/https://answers.unity.com/themes/thub/images/avi.jpg)