- Home /
Prefab Unable To Instantiate After Building As Application
Enemy = GameObject.Instantiate( Resources.Load<GameObject>("Prefabs/Enemy") ) as GameObject;
The above is the code that I used to Instantiate a prefab object into my game... It's working fine in the editor, but when I build it as a .exe or .apk, everything that I instantiate is not appearing.
I do have a Resources Folder, and I made sure the Prefab folder is in it. It loads in the Editor, but not in any other builds.
Ins$$anonymous$$d of loading it from resources. Type this code in the class:
public GameObject enemyObject;
and use this line:
Enemy = GameObject.Instantiate( enemyObject );
After editing this. Add your script (where you need) and set the value of enemyObject field. Then try
Not working...did you said :(
Build it to PC, still not spawning...shows in the editor though.
I have no idea why this would work but try this:
Enemy = GameObject.Instantiate(Resources.Load("Prefabs/Enemy"));
And, how is enemy defined?
Answer by unimechanic · Oct 08, 2014 at 01:40 PM
Could you duplicate the project, remove everything except the object in resources and try to instantiate it? If that works in the Editor but not in players, please submit a bug report with that sample project:
Your answer
Follow this Question
Related Questions
Instantiate: Create Connection 1 Answer
Instantiate problem in a RTS game 0 Answers
How To make unity work in Hebrew ? 1 Answer
Audio frequency sample on Android 1 Answer
Read Phone Info From Editor? 0 Answers