- Home /
How do I keep object threw loading a scene?
I am trying to keep the camera threw loading a new scene so I can have a loading menu. I tried a few things but I think I am just using it wrong.
here is the script
using UnityEngine;
using System.Collections;
public class LoadingScreen : MonoBehaviour {
public GameObject self;
public void Load(string g)
{
Application.LoadLevel(g);
}
void Awake()
{
DontDestroyOnLoad(self);
}
}
Answer by iamthecoolguy11 · Oct 10, 2014 at 04:03 AM
O wait lol this works I just have to have the parent instead otherwise it deletes the parent and the child.
using UnityEngine;
using System.Collections;
public class LoadingScreen : MonoBehaviour {
public GameObject self;
public void Load(string g)
{
Application.LoadLevel(g);
}
void Update()
{
DontDestroyOnLoad(self);
}
}
Answer by Redeemer86 · Oct 10, 2014 at 04:15 AM
DontDestroyOnLoad(this.gameObject);
... You might not be referencing the camera in your code probably, I think it should work if youve attached in the inspector.
Or Most probably, maybe your camera view angle after loading new scene is not oriented for proper view of the scene ... Maybe your camera is getting carried over to the next scene. Check whether your camera object is carried over to the next scene. Do not maximise your screen while running your scene and check in the hierarchy view on switching your scene. Where exactly in your code are you switching your scene though. I dont see that happening in code you provided.
Red.
Your answer
![](https://koobas.hobune.stream/wayback/20220613164756im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
An OS design issue: File types associated with their appropriate programs 1 Answer
Gear Vr Problems 0 Answers
How to Set Application.isFocused? 1 Answer