I'm creating a script to dynamicly load a menu with buttons. On every button there is a script that need to be run when the button has been clicked. For the button there is a prefab where the script in enabled on. After instantiating the prefab the script on it has been disabled. When I manually enable it by code it does nothing. When enabling the script using the editor it does wor.

My code for generating the buttons on my menu looks like:

 foreach (BuildingModel model in models)
          GameObject tempButton = Instantiate(buttonPrefab);

          PlaceObjectToScene script = tempButton.GetComponent<PlaceObjectToScene>();

           script.objectName = model.modelLocation + "/" + model.modelName + ".fbx";

            script.enabled = true;



I searched on the internet for some answers and found forum thread with the same issue but non of the sollutions works in my situation. Can someone help me how to enable the script that is default enabled on the prefab?

  • \$\begingroup\$ 1. Check if PREFABS have script enabled (not the objects on the scene). 2. Check if you have any errors in the console. If there's an error in the script, it will become disabled. \$\endgroup\$
    – Jacob
    Commented Jun 18, 2017 at 18:52
  • \$\begingroup\$ Script is enabled in the prefab and did not got any errors in the script \$\endgroup\$
    – JimmyD
    Commented Jun 18, 2017 at 19:03
  • \$\begingroup\$ Assets -> Export Package and upload it on Dropbox or somewhere. There's no error in this code, I'll take a look. \$\endgroup\$
    – Jacob
    Commented Jun 18, 2017 at 19:04
  • \$\begingroup\$ You can find the assets here drive.google.com/file/d/0B7tTtE3e6xrTVERhMWMybE1ndWs/…. \$\endgroup\$
    – JimmyD
    Commented Jun 19, 2017 at 16:00
  • \$\begingroup\$ It's about PreFab with name MenuButton. Script LoadSubMenu will initialize Prefab and PlaceObjectToScene script is in the prefab. \$\endgroup\$
    – JimmyD
    Commented Jun 19, 2017 at 16:03

1 Answer 1


Ok found the issue. It was an error in my code. I had added a enabled = false in there. And is not the correct behaviour of my script.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .