- Home /
Running scripts from editor
Hello, I've received a scripts hath creates list of prefabs from pictures, and store them in AssetDatabse. However, this script only runs from editor (it has the line: if UNITY_EDITOR endif.
How can I run this script
Where can I locate the prefabs that was created?
How can I access those prefabs from other scripts within the same project?
Thank you
Answer by nj4242 · Sep 07, 2016 at 05:08 AM
Unity provides option for both calling objects at the beginning as well as runtime, means from script as well as from the Inspector(Editor). Since script is a component and prefabs are GameObjects you can reference it anywhere within your project.
For Script you can run it by :
Gameobject myScript;
myScript = GetComponent (other_Script_Name);
As for prefabs you can simply find it by :
GameObject go = (GameObject)Instantiate(Resources.Load("MyPrefab"));
Or
GameObject go = Instantiate(Resources.Load("MyPrefab")) as GameObject;
Your answer
Follow this Question
Related Questions
creating and using list of prefabs 2 Answers
Counting prefabs in screen?,Problem with counting prefabs in screen 1 Answer
how to allow the key to only open 1 door rather than all of them? 0 Answers
Why when using get; set; in one script i'm getting null in other script that use it ? 1 Answer
store many GameObjects 2 Answers