/// <summary> /// 资源载入的资源 /// </summary> /// <param name="loader"></param> private void instanceCutscene(ALoadOperation loader) { GameObject gObj = loader.GetAsset <GameObject>(); if (gObj == null) { Debug.LogError(string.Format("找不到加载的剧情片段资源!路径:{0}", loader.assetPath)); return; } gObj = GameObject.Instantiate(gObj); gObj.name = gObj.name.Replace("(Clone)", ""); GameObject.DontDestroyOnLoad(gObj); caches.Add(gObj); PlotCamera[] plotCameraArr = gObj.GetComponentsInChildren <PlotCamera>(); for (int i = 0; i < plotCameraArr.Length; i++) { plotCameraArr[i].gameObject.SetActive(false); } Cutscene cutscene = gObj.GetComponent <Cutscene>(); cutscene.Optimize(); cutscene.CutscenePaused += pauseCutsceneEvent; cutscene.CutsceneFinished += finishCutsceneEvent; int cutsceneId = Convert.ToInt32(gObj.name.Substring(8)); this.catchCutscenes[cutsceneId] = cutscene; gObj.SetActive(false); }
/// <summary> /// 异步加载剧情片段 /// </summary> /// <param name="cutsceneId"></param> /// <returns></returns> private IEnumerator loadCutsceneAsync(int cutsceneId) { string cutscenePath = string.Concat("Prefab/Cutscene/Cutscene", cutsceneId); ALoadOperation operation = ResourceManager.LoadBundleAsync(cutscenePath); yield return(this.StartCoroutine(operation)); GameObject gObj = operation.GetAsset <GameObject>(); if (gObj == null) { Debug.LogError(string.Format("找不到加载的剧情片段资源!路径:{0}", cutscenePath)); yield break; } gObj = GameObject.Instantiate(gObj); gObj.name = gObj.name.Replace("(Clone)", ""); GameObject.DontDestroyOnLoad(gObj); PlotCamera[] plotCameraArr = gObj.GetComponentsInChildren <PlotCamera>(); for (int i = 0; i < plotCameraArr.Length; i++) { plotCameraArr[i].gameObject.SetActive(false); } yield return(null); curCutscene = gObj.GetComponent <Cutscene>(); curCutscene.Optimize(); yield return(null); curCutscene.CutscenePaused += pauseCutsceneEvent; curCutscene.CutsceneFinished += finishCutsceneEvent; }