unity, LoadLevelAdditive到帧末才完成

Application.LoadLevelAdditive文档中说:

LoadLevel and LoadLevelAdditive don't happen immediately - a new level is loaded after the current game frame finishes. isLoadingLevel returns true if a level load was requested this frame already.

即LoadLevelAdditive到帧末才完成,所以要想获得新load进来的场景中的节点,不能立即find,可用Application.isLoadingLevel来判断load是否完成。如下所示:

Application.LoadLevelAdditive (sceneName);
while(Application.isLoadingLevel==true){
  yield return null;
}//loading done

Transform sceneRoot = GameObject.Find(sceneRootName);

原文地址:https://www.cnblogs.com/wantnon/p/5617223.html