private void OnSceneLoadComplete() { LogicResouce lRes = ResourceManager.Instance.GetLogicRes(SceneRes); //LogicResourceBuilder builder = null; LightmapSettings.lightmapsMode = LightmapsMode.Single; LightmapSettings.lightmapsMode = LightmapsMode.Single; Dictionary <int, Texture2D> lightMapDic = new Dictionary <int, Texture2D>(); foreach (string s in lRes.phyResList) { if (s.Contains("LightmapFar")) { string[] strs = s.Split(new char[] { '-', '.' }); if (strs != null && strs.Length > 0) { int index = Int32.Parse(strs[strs.Length - 2]);//strs[Length - 1]; if (lightMapDic.ContainsKey(index)) { } else { lightMapDic.Add(index, ResourceManager.Instance.GetPhyRes(s).getTexture()); } } } if (s.Contains("LightProbe")) { PhyResouce probe = ResourceManager.Instance.GetPhyRes(s); if (probe != null) { LightProbes probes = (LightProbes)probe.assetBundle.mainAsset; LightmapSettings.lightProbes = probes; } } } LightmapData[] ldarr = new LightmapData[lightMapDic.Count]; foreach (KeyValuePair <int, Texture2D> kv in lightMapDic) { LightmapData ld = new LightmapData(); ld.lightmapFar = kv.Value; ldarr[kv.Key] = ld; } LightmapSettings.lightmaps = ldarr; PhyResouce res = ResourceManager.Instance.GetPhyRes(SceneRes); UnityEngine.Object obj = res.assetBundle.mainAsset; GameObject.Instantiate(obj); }
private bool isAllLogicComplete() { foreach (LogicLoadRequest r in logicReqDic.Values) { LogicResouce res = ResourceManager.Instance.GetLogicRes(r.resPath); if (res == null) { return(false); } } return(true); }
//更新 public void Update() { if (isAllLogicRootComplete() == false) { foreach (LogicLoadRequest logicLoadReq in logicReqDic.Values) { if (curLoadCount < aSyncLoadCount) { if (ResourceManager.Instance.GetLogicRes(logicLoadReq.resPath) != null) { logicLoadReq.status = LogicLoadRequest.LOADSTATUS.END; } else { if (logicLoadReq.status == LogicLoadRequest.LOADSTATUS.WAIT) { ResourceManager.Instance.LoadImpl(logicLoadReq.resPath, LogicResouce.getRootResType(logicLoadReq.resType), (path) => { AssetBundle ab = ResourceManager.Instance.GetPhyRes(path).assetBundle; StringScriptableObject holder = (StringScriptableObject)ab.Load("DependentBundleNames"); LogicResourceBuilder logicBuilder = new LogicResourceBuilder(); logicBuilder.resPath = logicLoadReq.resPath; logicBuilder.logicResType = logicLoadReq.resType; if (holder != null) { if (holder.content != null) { foreach (string s in holder.content) { // GameDefine.GameMethod.DebugError("got dependency:" + s); AddPhyFile(s, PhyResouce.EPhyResType.EPhyResPrefab); logicBuilder.resLists.Add(s); } } } ResourceManager.Instance.AddLogicResourceBuilder(logicBuilder); }); logicLoadReq.status = LogicLoadRequest.LOADSTATUS.START; } } } } } else { foreach (PhyLoadRequest phyLoadReq in phyReqDic.Values) { if (curLoadCount < aSyncLoadCount) { ResourceManager.Instance.LoadImpl(phyLoadReq.resPath, phyLoadReq.resType); } } } UpdateProgress(); }
// public void Update() { if (loadProcess != null) { if (loadProcess.isLoading == true) { loadProcess.Update(); } } List <string> removeLoadList = new List <string>(); //遍历loadimplement foreach (LoadImplement l in loadImplDic.Values) { if (l.www.isDone == true) { if (l.www.error == null) { if (l.createReq == null) { l.createReq = AssetBundle.CreateFromMemory(l.www.bytes); } if (l.createReq.isDone == true) { // GameDefine.GameMethod.DebugError("Load Res Success:" + l.resPath); PhyResouce phyRes = new PhyResouce(); phyRes.resPath = l.resPath; phyRes.phyResType = l.phyResType; phyRes.assetBundle = l.createReq.assetBundle; //if(phyResDic.ContainsKey(phyRes.resPath) == true) //{ // Debug.LogError("already have:"+phyRes.resPath); //} //else // Debug.LogError("phy res :" + phyRes.resPath); phyResDic.Add(phyRes.resPath, phyRes); // } removeLoadList.Add(l.resPath); } } else { GameDefine.GameMethod.DebugError("Load Res Failed:" + l.www.url + "======" + l.resPath + " error is:" + l.www.error.ToString()); removeLoadList.Add(l.resPath); } } } foreach (string s in removeLoadList) { LoadImplement l = getLoadImplement(s); if (l.onResLoaded != null) { l.onResLoaded(l.resPath); } loadImplDic.Remove(s); } List <string> removeBuilderList = new List <string>(); foreach (LogicResourceBuilder builder in logicResBuilder.Values) { bool allLoaded = true; foreach (string s in builder.resLists) { if (GetPhyRes(s) == null) { allLoaded = false; break; } } if (allLoaded == true) { removeBuilderList.Add(builder.resPath); if (builder.onLogicResourceBuilded != null) { builder.onLogicResourceBuilded(builder.resPath); } LogicResouce logicRes = new LogicResouce(); logicRes.resPath = builder.resPath; logicRes.logicResType = builder.logicResType; logicRes.phyResList = builder.resLists; if (logicResDic.ContainsKey(logicRes.resPath) == true) { logicResDic[logicRes.resPath] = logicRes; } else { logicResDic.Add(logicRes.resPath, logicRes); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } foreach (string s in removeBuilderList) { logicResBuilder.Remove(s); } // }