- Home /
Question by
Hjalte · May 18, 2014 at 02:09 AM ·
c#gameobjectprefabdontdestroyonloadpublic
Setting public GameObject to a different Prefab through code
okay so i have a pick up script which asks for 3 different objects. Since im using the DontDestroyOnLoad on my character this means that i can only use those 3 objects in all my scenes. I want to change which prefabs are to be picked up through code.
Like I wanna tell it that if the loadedscene is 2 then item is thisPrefab and if loadedscene is 4 then item is thisOtherPrefab
Comment
To me it looks like you mostly answered your own question. Just make a few if
statements using Application.loadedLevel
to deter$$anonymous$$e what scene you are using and then switch the prefab.