- Home /
how to access objects in another scene but in the same project?
i wanna know how to get it that when i collide with the end of level object another level becomes available. i have the collision part but obviously my level select screen is a different scene, so when i collide with the end of level object the trigger object for the next level becomes active. could someone help me with this issue? All help is appreciated. Thanks!
Answer by skovacs1 · Aug 24, 2010 at 09:35 PM
You would use Application.LoadLevel or Application.LoadLevelAdditive or Application.LoadLevelAsync or Application.LoadLevelAdditiveAsync to load scenes. See Application for more details.
To preserve data between scenes, you would want to use DontDestroyOnLoad or like spinalJack said, use player prefs.
Please see the latter portion of the 3D Platformer Tutorial for example usage.
Answer by spinaljack · Aug 24, 2010 at 09:33 PM
You can use PlayerPrefs to save level unlocks.
e.g.
PlayerPrefs.SetInt("Level2Unlocked",1);
To check if a level is unlocked you go like so:
if(PlayerPrefs.HasKey("Level2Unlocked")){
Application.LoadLevel(2);
}
Check out the docs for other data types you can save in player prefs
Your answer
![](https://koobas.hobune.stream/wayback/20220613072006im_/https://answers.unity.com/themes/thub/images/avi.jpg)