Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When loading a new level, <code>scene</code>, all Game Objects of the previous scene are destroyed by Unity.</p> <p><strong>If you want to protect a Game Object you can use the function.</strong></p> <pre><code>DontDestroyOnLoad(gameObject); </code></pre> <p>It is important to note that when you say: <code>this.gameObject</code> you are pointing to pretty much the same thing, it just happens that <code>this</code> points directly to the script attached to that gameObject. So you don't need the <code>this</code> part, just <code>gameObject</code> will do. </p> <p>Ideally you could protect that gameObject inside <code>void Awake()</code></p> <pre><code>void Awake() { DontDestroyOnLoad(gameObject); } </code></pre> <p>The above code will prevent Unity from destroying that gameObject unless your game closes completely or at a later point you call <code>Destroy()</code> on it. That means you can change from scene to scene and the gameObject will survive. However, if you make it back to the scene that creates that gameObject you are protecting you may run into problems if you do not have the logic implemented that prevents you from protecting a second, third, or many of that gameObject.</p> <p><strong>Your second question</strong>, if I understand it correctly: You want to send mail when you change scenes, but your progress bar wont progress while changing scenes, it just stays there, static. </p> <p>If that is the case then your problem is in <code>Application.LoadLevel(sceneName);</code> If you have the free version of Unity, then you need to come up with your own creative way of showing that progress bar, because <code>Application.LoadLevel()</code> will halt everything until it takes you to the new scene.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload