Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

How to instantiate from prefab, not from instance?

$
0
0
I'm instantiating a game object from a reference to a prefab, like this: var starSystem : GameObject; function OnTriggerExit2D (other: Collider2D) { var newSystem : GameObject = Instantiate(starSystem, newSystemPosition, Quaternion.identity); } The first time the function gets called, it creates a clone of the prefab that starSystem refers to, but every subsequent time, it creates a clone of the previous clone, not a clone of the unmodified prefab in the project. I just want to instantiate from the prefab, not from a clone; I definitely haven't changed the reference from a reference to the prefab, to a reference to the last clone, in a script anywhere. What's going on? Edit -- It's probably of note that the script which instantiates the new clone is a component in an instance of the prefab it's trying to instantiate.

Viewing all articles
Browse latest Browse all 508