Instantiating a gameobject form another scene.

In my 1st scene i am selecting a gameobject. That game object should load in the second screen. Is it possible to get the selected gameobject from first scene to the next scene and if possible can i instantiate it?

With the additional information you have given in the comment, sounds like you would just have to do this:

  • Call DontDestroyOnLoad on your selected GameObject as mentioned above in the comments (yes you can pass in a component, script, as well if need be). What that method does, is it makes the Object that is passed into the function to not be deleted from the Hierarchy when the next scene is loaded. Therefore, you will be able to have access to it in the next scene.

      public class CarScene : MonoBehaviour {
          public GameObject selectedCar;
          void Update() {
              //Perform update logic here.. i.e. changing the selected car, etc.
          void OnGUI() {
              if(GUI.Button(<Rect>, "Select")) {

Of course the script you will want to have will be completely different than this I’m sure (filled in Rect and string variables, etc. as well), but this should get you started. If you have any questions, feel free to ask and I will do the best I can to update what I’ve given to you.


There are two ways you can have a script on a GameObject.

  1. Manually add the script component to the GameObject in the Hierarchy. If you don’t want it enabled for a specific scene you can either disable it by clicking the checkbox next to the script component’s name (assuming the scene you are currently on should have it disabled) or disable it programmatically. Then when you need to use the component you can just enable it again via code. This all depends on what you need though, but you can use GetComponent to get reference to the script:

    public class ManageComponent : MonoBehaviour {
        public Car car;
        void Start() {
            car = GetComponent<Car>();
            car.enabled = false;
  2. Programmatically add the script component using AddComponent:

    public class AddScriptToGameObject : MonoBehaviour {
        public GameObject carGameObject;
        public Car addedScript;
        void Start() {
            addedScript = carGameObject.AddComponent<Car>();
            addedScript.enabled = false;