Application.LoadLevel & Object.DontDestroyOnLoad

Application.LoadLevel

  

  只有在File->Build Setting中设置了的按钮才能被加载。

  当level加载完成后,MonoBehaviour.OnLevelWasLoaded is called on all active game objects。

  When loading a new level all game objects that have been loaded before are destroyed. If you want to let an object survive when loading a new level, use Object.DontDestroyOnLoad.

  Calling LoadLevel will update Application.loadedLevel and Application.loadedLevelName

参考:file://localhost/Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/Application.LoadLevel.html

Object.DontDestroyOnLoad

  When loading a new level all objects in the scene are destroyed, then the objects in the new level are loaded. In order to preserve an object during level loading call DontDestroyOnLoad on it. If the object is a component or game object then its entire transform hierarchy will not be destroyed either.

参考:file://localhost/Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/Object.DontDestroyOnLoad.html

Application.LoadLevel & Object.DontDestroyOnLoad,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。