How can I in-script create gameobject from prefab?
Most important is link gameobject to prefab. When I use AssetDatabase.LoadAssetAtPath()
this really create gameobject with prefab structure, but in Hierarchy tab its not blue like gameobject created manually from prefab.
I dont need Runtime support, only Editor. The game is not running.
I'm creating an editor for the scene builder in my project and I do not want to drag each time a lot of prefabs to the editor manually. Whether it is possible to do without dragging prefabs?
When I say "blue gameobject" I mean
Are you talking about instantiating the prefab when the game is running and it not having the blue text at this time?
Answer by AlecGamble · Apr 14, 2016 at 12:12 PM
I believe the blue text is to show that the instance of the object in the scene can interact with the prefab in the inspector:
If you are instantiating objects from a prefab they only exist whilst the game is running and changes to them cannot be applied to the prefab.
I often just find it easiest to declare the prefab as a public GameObject in the script and then drag the prefab from the Project files onto the inspector.
Answer by carlqwe · Apr 14, 2016 at 11:04 AM
Well i dont really think i understand what you're going for here, but Instantiate(objectName, SpawnpointName.transform.position,Quaternion.Identity)
Work best if you want to spawn a GAMEOBJECT from a PREFAB into a scene at runtime.