У меня есть GameController
в Scene1
, и я сделал это DontDestroyOnLoad
.
Когда я загрузил Scene2
, я пытаюсь найти GameObject
в Scene2
иobj2
это null
, а obj1
нет.
Почему?
Как я могу найти GameObjectInScene2
?
public class GameController: MonoBehaviour
{
private void Awake()
{
DontDestroyOnLoad(this);
}
private void Start()
{
SceneManager.LoadScene("Scene2");
GameObject obj1 = GameObject.Find("GameObjectInScene1");
GameObject obj2 = GameObject.Find("GameObjectInScene2");
}
}