- Home /
 
               Question by 
               taha4567123 · Feb 08, 2021 at 04:34 PM · 
                gameobjectscenesdontdestroyonload  
              
 
              Unity 2d select 2 object on another 2 scenes
Hi, my name is Taha.
I wanna select 2 object in a script but this 2 object is on another 2 scenes.
I add a DontDestroyOnLoad();
If scene is 0 happend anything, If scene is 1 happend anything.
How can i do that or can i do that?
my code:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class game : MonoBehaviour
 {
     public GameObject object1;//object on first scene
     public GameObject object2;//object on second scene
 
     public float scene;
 
     private Rigidbody2D rb1, rb2;
     void start()
     {
         rb1 = object1.GetComponent<Rigidbody2D>();
         rb2 = object2.GetComponent<Rigidbody2D>();
 
         DontDestroyOnLoad(gameObject);
     }
     void update()//this is a example
     {
         if (scene == 0)
         {
             //bla
         }
         if (scene == 1)
         {
             //bla
         }
     }
 }
 
               Comment
              
 
               
              Answer by wannaMakeAGame · Feb 09, 2021 at 10:03 PM
Scriptable Object kullanabilirsin. Onlar sahnelerin dışında olduğu için istediğin zaman değiştirirsin.
Your answer
 
 
             Follow this Question
Related Questions
Continuous AudioSource in DontDestroyOnLoad 1 Answer
How to link words from different scene 1 Answer
GameObject can be seen in scene tab but cannot be seen in game tab 1 Answer
Confusion about DontDestroyOnLoad and very large scenes... 1 Answer
access a gameobject from another scene at design-time 2 Answers
