Vehicle Selection Scenerio,Vehicle Selection Scenerio...Need Help

Need Unity Help…
I am working on a scenario in unity where in one unity scene I have my main menu which contains buttons for vehicle selection, the problem is that how can I spawn the selected vehicle(prefeb) in a specific scene when button for that specific vehicle is clicked.

You need to have the selection persist between scenes. So you can either save it with player prefs or make it serizable. Or you can use DontDestroyOnLoad() to make sure the class persists between scenes. Then the GameObject value that refers to the vehicle prefab should be saved in the selection scene on the class that is persistent and then when you are starting the next scene, instantiate the selected vehicle into the start position.


If you want to do it with player prefs, you could do something like this:

PlayerPrefs.SetInt("carSelectionIndex", selectedCarIndex);

that would be in your selection scene and then you would get the int in the next scene like this:

int carId = PlayerPrefs.GetInt(“carSelectionId”);

And use a list to store your cars and carId should be the index of the vehicle chosen in you list of cars.


If you want to go the serializable route, that is a bit more in depth, I would suggest you start with player prefs or DontDestroyOnLoad() to get started. Cheers