/// <summary> /// 子場景如果沒Load進來就load子場景 /// (在流程中的Awake加這個檢查,就能在Editor模式下,開場景時,就把子場景一起load進來). /// </summary> /// <param name="sceneName"></param> public void LoadChildScenesIfNotLoad(string sceneName) { for (int i = 0; i < loadSceneDataList.Count; i++) { ScenePathData parentScene = loadSceneDataList[i].parentScene; List <ScenePathData> childScenes = loadSceneDataList[i].childSceneList; if (parentScene.name == sceneName) { LoadChildScene(childScenes, false, true); } } }
/// <summary> /// 分析子場景資料. /// </summary> /// <param name="parentNode">xml父節點</param> /// <param name="sceneDataList">子場景List</param> void ParseChildScenesData(XmlNode parentNode, List <ScenePathData> sceneDataList) { for (int i = 0; i < parentNode.ChildNodes.Count; i++) { //! 忽略註解. if (parentNode.ChildNodes[i].NodeType == XmlNodeType.Comment) { continue; } ScenePathData scenePathData = new ScenePathData(); scenePathData.name = parentNode.ChildNodes[i].Attributes["Name"].InnerText; scenePathData.path = parentNode.ChildNodes[i].Attributes["Path"].InnerText; sceneDataList.Add(scenePathData); } }
/// <summary> /// 取得要Load場景的全部實際資料. /// </summary> /// <param name="sceneName"></param> /// <param name="async"></param> /// <param name="asyncSceneAutoActive"></param> /// <returns></returns> LoadSceneRealData GetLoadSceneRealData(string sceneName, bool async, bool asyncSceneAutoActive) { LoadSceneRealData sceneRealData = new LoadSceneRealData(); sceneRealData.async = async; sceneRealData.asyncSceneAutoActive = asyncSceneAutoActive; LoadSceneData sceneData = FindSceneData(sceneName); //! 取得Parent SceneName. string parentName = sceneData.parentScene.name; //! 如果有idType,就取得遊戲中對應id. if (sceneData.parentScene.idType != "") { int id = GetIdByIdType(sceneData.parentScene.idType); parentName += id.ToString(); } sceneRealData.parentSceneName = parentName; //! 取得Child SceneName. for (int i = 0; i < sceneData.childSceneList.Count; i++) { ScenePathData childPathData = sceneData.childSceneList[i]; string childName = childPathData.name; //! 如果有idType,就取得遊戲中對應id. if (childPathData.idType != "") { int id = GetIdByIdType(childPathData.idType); childName += id.ToString(); } sceneRealData.childSceneNameList.Add(childName); } return(sceneRealData); }