Question by
Raven_Gothchild · Nov 17, 2016 at 04:28 PM ·
gameobjectprefabarrayeditor-scripting
How can I get a reference to a Prefab in the Asset folder without instantiating it?
I'm working on an Editor tool which I create a new game object via a menu item, I then was the custom inspector to fill an Array of available prefabs before I instantiate a subset them as children of the original GameObject.
I can instantiate with Resource.Load("prefab") and then load the Array with the cloned GameObjects but that is not what I want. The idea is that is the user updates the Array of prefabs in the inspector then the objects in the scene view will update to reflect that change.
Any help, much appreciated. :)
Comment
Best Answer
Answer by Filhanteraren · Nov 17, 2016 at 04:35 PM
Object prefab = AssetDatabase.LoadAssetAtPath("Assets/GameObject.prefab", typeof(GameObject));
Will get you a reference to a Prefab.
Thanks. please notice that the file extension is important.