private void LoadMode() { //LoaderPool.InnerLoad(targetVO.modelUri, SimpleLoadDataType.prefabAssetBundle, onloaded, new object[1] { targetVO }); string outUrl = targetVO.modelUri;// "http://midea-products.oss-cn-shanghai.aliyuncs.com/8b7df9b0-28f5-4c88-a412-324284ccc923/model.assetbundle";//10.0.21.27/yy/model.assetbundle"; loader = LoaderPool.OutterLoad(outUrl, SimpleLoadDataType.prefabAssetBundle, onloaded, targetVO, onloadedBforClone); }
/// <summary> /// 获得加载器 /// </summary> /// <param name="type">类型</param> /// <param name="path">路径</param> /// <param name="param">附加参数</param> /// <param name="async">异步</param> /// <returns>加载器</returns> public Loader GetLoader(LoaderType type, string path, object param, bool async) { if (!m_DicLoaderDatas.TryGetValue(path, out LoaderData loaderData)) { loaderData = LoaderDataPool.Get(type); if (loaderData == null) { loaderData = new LoaderData { referenceCount = 0, loader = LoaderPool.Get(type), completeCallbacks = new List <LoadCompleteCallback>() }; } loaderData.loader.Init(path, param, null, OnLoadCompleted, async); m_DicLoaderDatas.Add(path, loaderData); } if (!async) { loaderData.loader.async = false; } ++loaderData.referenceCount; return(loaderData.loader); }
public void OnUpdate() { int index = 0; Loader loader = null; while (index < m_Loaders.Count) { loader = m_Loaders[index]; loader.OnUpdate(); if (loader.isFinish) { m_Loaders.RemoveAt(index); if (!m_LoaderQueue.Contains(loader)) { LoaderPool.Release(loader); } CheckNextTask(); } else { ++index; } } UpdateAsyncCallback(); }
private Loader AddLoadTask(LoaderType type, string path, object param, UnityAction <Loader, object> callback, bool async) { Loader loader = LoaderPool.Get(type); loader.Init(path, param, OnLoadProgress, callback, async); if (!async) { m_Loaders.Add(loader); loader.Load(); } else { m_LoaderQueue.Enqueue(loader); if (m_CountTotal != 0) { ++m_CountTotal; } } if (0 == m_Loaders.Count) { CheckNextTask(); } return(loader); }
public void setTexture(GameObject go, string path, string isLocal) { if (isLocal == "local") { LoaderPool.InnerLoad(path, SimpleLoadDataType.texture2D, onLoaded, go); } else { LoaderPool.OutterLoad(path, SimpleLoadDataType.texture2D, onLoaded, go); } }
private void ServerOfferLoadReady(MyEvent obj) { for (int i = 0; i < serverOfferCache.cacheOfferList.Count; i++) { string id = serverOfferCache.cacheOfferList[i]; if (mainpageData.HasPriceData(id)) { continue; } LoaderPool.CacheLoad(id, SimpleLoadDataType.JsonOffer, null); } }
private void LocalOfferLoadReady(MyEvent obj) { for (int i = 0; i < localOfferCache.cacheOfferList.Count; i++) { int tempId = localOfferCache.cacheOfferList[i]; if (mainpageData.HasPriceData(tempId.ToString())) { continue; } LoaderPool.CacheLoad(tempId, SimpleLoadDataType.JsonOffer, OnPriceLoaded); } }
public void SetCurrentData(OriginalProjectData project, bool saveToLocal = true) { //SetToLocal(currentData); undoDatas.Clear(); redoDatas.Clear(); currentData = new TotalData(); currentData.SaveId = 0; currentData.data = project.data; currentData.schemeManifest.id = project.id; currentData.schemeManifest.templateId = project.templateId; currentData.schemeManifest.meta = project.meta; currentData.schemeManifest.name = project.name; currentData.schemeManifest.description = project.description; currentData.schemeManifest.tempId = project.tempId; currentData.schemeManifest.isNew = project.isNew; currentData.schemeManifest.version = project.version; currentData.schemeManifest.prices.Clear(); currentData.schemeManifest.tempEffectMetas = project.tempEffectMetas; //是否为样板间 currentData.schemeManifest.isTemplate = project.isTemplate; if (project.priceIdList != null) { currentData.schemeManifest.prices.AddRange(project.priceIdList); for (int i = 0; i < project.priceIdList.Count; i++) { string id = project.priceIdList[i]; if (mainpageData.HasPriceData(id)) { continue; } int tempId; if (int.TryParse(id, out tempId)) { LoaderPool.CacheLoad(tempId, SimpleLoadDataType.JsonOffer, OnPriceLoaded); } else { LoaderPool.CacheLoad(id, SimpleLoadDataType.JsonOffer, OnPriceLoaded); } } } //ClearView(); RefreshView(); if (saveToLocal == true) { jsonCacheManager.SaveSchemeToLocal(); } schemeControl.dispatchEvent(new SchemeEvent(SchemeEvent.ChangeScheme)); Resources.UnloadUnusedAssets(); }
private void EnterDesign(MsgFromIOS.InfoFromIOS info) { GlobalConfig.running = true; if (Application.platform != RuntimePlatform.IPhonePlayer) { info.msg = new List <object>() { "http://cf-hsm-prod-assets.homestyler.com/i/4abd1bba-6d61-481e-9008-25295599e006/iso.jpg" }; } switch (info.enterType) { case "1": undoHelper.CreatNewEnter(); mainpageMachine.setState(ToTwoDState.Name); break; case "2": //进入2D case "3": //进入3D case "4": //进入新建方案2D 预置指定模板 case "5": //进入新建方案3D 预置指定模板 mainPageUIController.dispatchEvent(new LoadEvent(LoadEvent.OpenLoadingPage)); string id = info.projectId; int tempId = info.tempId; if (string.IsNullOrEmpty(id) == true) { if (localCache.HasCached(tempId)) { LoaderPool.CacheLoad(tempId, SimpleLoadDataType.JsonScheme, OnCacheLoaded, info); return; } } else { if (serverCache.HasCached(id)) { LoaderPool.CacheLoad(id, SimpleLoadDataType.JsonScheme, OnCacheLoaded, info); return; } } LoaderPool.OutterLoad(info.json, SimpleLoadDataType.Json, onloaded, info); break; default: break; } }
public override void Render() { base.Render(); //EffectImage; string [] strs = itemData.path.Split(new string[] { "--" }, StringSplitOptions.RemoveEmptyEntries); if (strs.Length == 2) { string path = strs[1]; LoaderPool.OutterLoad(path, SimpleLoadDataType.texture2D, onLoadedSetTexture, null); //SetTextureTool.SetTexture(EffectImage, path, "notLocal"); } else { Debug.Log("itemData.meta strs.Length != 2"); } }
private void ClearLoader() { for (int i = 0; i < m_Loaders.Count; ++i) { m_Loaders[i].Stop(); } for (int i = 0; i < m_Loaders.Count; ++i) { LoaderPool.Release(m_Loaders[i]); } for (int i = 0; i < m_LoaderQueue.Count; ++i) { LoaderPool.Release(m_LoaderQueue.Dequeue()); } m_Loaders.Clear(); m_LoaderQueue.Clear(); }
public void setTexture(RawImage go, string path, string isLocal) { if (go == null) { Debug.LogWarning("setTexture RawImage go == null"); return; } if (string.IsNullOrEmpty(path)) { Debug.LogWarning("setTexture path == null"); return; } if (isLocal == "local") { LoaderPool.InnerLoad(path, SimpleLoadDataType.texture2D, onLoaded, go); } else { LoaderPool.OutterLoad(path, SimpleLoadDataType.texture2D, onLoaded, go); } }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="type">加载类型 0本地Resouce 1本地StreamingAsset 2远程</param> /// <param name="data"></param> public void LoadPrefab(string path, int type, Action <UnityEngine.Object, object> Loaded, object data = null) { onLoaded = Loaded; bringData = data; if (type == 0) { loadpath = path.Split('.')[0]; UnityEngine.Object obj = GameObject.Instantiate(Resources.Load(loadpath)); if (Loaded != null) { onLoaded(obj, bringData); } } else if (type == 1) { loadpath = "UI/panel/" + path; LoaderPool.InnerLoad(loadpath, SimpleLoadDataType.prefabAssetBundle, OnLoaded, null); //loader.Load(); } else { Debug.LogWarning("目前只有本地"); } }
private void onloaded(object obj) { SimpleOutterLoader loader = obj as SimpleOutterLoader; if (loader.state == SimpleLoadedState.Failed) { //Debug.LogError(loader.uri); return; } string json = loader.loadedData.ToString(); object jsonData = MyJsonTool.FromJson(json); MsgFromIOS.InfoFromIOS info = loader.bringData as MsgFromIOS.InfoFromIOS; OriginalProjectData data = new OriginalProjectData(); Dictionary <string, object> dic = jsonData as Dictionary <string, object>; ///在线端数据 if (dic.ContainsKey("products")) { //data.DeSerialize(dic); } ///移动端新数据 else if (dic.ContainsKey("version")) { data.DeSerialize(dic); } ///移动端旧数据 或 错误数据 else { data.DeSerialize(dic); } switch (info.enterType) { case "4": case "5": data.isTemplate = true; data.isNew = true; data.templateId = info.projectId; data.id = ""; data.tempId = jsonCacheManager.GetNewSchemeTempId(); break; default: data.id = info.projectId; data.tempId = info.tempId; data.isNew = false; break; } //data.templateId = info.templateId; data.tempEffectMetas.Clear(); List <object> matelist = info.msg as List <object>; for (int i = 0; i < matelist.Count; i++) { data.tempEffectMetas.Add(matelist[i].ToString()); } //放到队列加载后 //undoHelper.SetCurrentData(data); switch (info.enterType) { case "3": case "5": mainpageMachine.setState(ToThreeDState.Name); break; default: mainpageMachine.setState(ToTwoDState.Name); break; } float minX = 0; float maxX = 0; float minY = 0; float maxY = 0; for (int i = 0; i < data.data.pointList.Count; i++) { Vector2 v2 = data.data.pointList[i].pos; if (v2.x < minX) { minX = v2.x; } if (v2.x > maxX) { maxX = v2.x; } if (v2.y < minY) { minY = v2.y; } if (v2.y > maxY) { maxY = v2.y; } } Vector2 pos = Vector2.zero; pos.x = (minX + maxX) / 2; pos.y = (minY + maxY) / 2; CameraControler.Instance.ResetAllCamera(pos); QueueSimpleLoader queueloader = new QueueSimpleLoader(data); for (int i = 0; i < data.data.productList.Count; i++) { Product product = data.data.productList[i]; if (product.assetBundlePath.IndexOf("http://") == -1) { continue; //if (string.IsNullOrEmpty(product.model3d)) continue; } SimpleOutterLoader outLoader = LoaderPool.WaitOutterLoad(product.assetBundlePath, SimpleLoadDataType.prefabAssetBundle, null, product, onloadedBforClone); queueloader.AddQueueItem(outLoader); } if (queueloader.getCount != 0) { queueloader.addEventListener(LoadEvent.QueueProgress, OnAllProductProgress); queueloader.addEventListener(LoadEvent.QueueComplete, OnLoadedAllProduct); } else { undoHelper.SetCurrentData(data); } }
public override void enter() { base.enter(); if (viewTarget == null) { target = viewData as ProductData; targetWall = target.targetWall; targetProduct = mainpagedata.getProduct(target.seekId); targetSize = targetProduct.size; targetVO = mainpagedata.getGoods(target.seekId); optionsController.selectMachine = selectGoods3DMachine; GameObject go; if (selectEmtyObj == null) { go = GameObject.CreatePrimitive(PrimitiveType.Cube); selectEmtyObj = new GameObject("selectEmtyObj"); go.transform.parent = selectEmtyObj.transform; } else { go = selectEmtyObj.transform.GetChild(0).gameObject; } selectEmtyObj.gameObject.SetActive(true); Vector3 size = targetProduct.size; go.transform.localScale = size; go.transform.localPosition = size.y / 2 * Vector3.up; targetObj = selectEmtyObj; Vector3 v3 = target.position; v3.y = target.height; switch (targetVO.type) { case 3: //吊顶 { v3.y = target.height - targetSize.y; } break; case 4: //地毯 { v3.y = -0.001f + target.height; } break; case 5: //天花板 { v3.y = target.height - 0.001f; } break; default: break; } targetObj.transform.position = v3; string outUrl = targetVO.modelUri; loader = LoaderPool.WaitOutterLoad(outUrl, SimpleLoadDataType.prefabAssetBundle, onloaded, null); //在3D刷新时移除 3D自己刷新会去加载拥有的模型 若不加入 加载过程中被刷新会在加载完成时候出现多余项 view3D.loaders.Add(loader); return; } target = (viewTarget as Goods3DView).data; targetWall = target.targetWall; targetVO = mainpagedata.getGoods(target.seekId); targetProduct = mainpagedata.getProduct(target.seekId); targetSize = targetProduct.size; optionsController.selectMachine = selectGoods3DMachine; targetObj = viewTarget.gameObject; RefreshRotateAndMoveHeight(true); selectGoods3DMachine.setState(EditTypeOnSelect.Free); cameraMachion.addEventListener(CameraEvent.ViewChange, OnViewChange); }
public Mode2DPrefabs() { LoaderPool.InnerLoad("2D/prefab/iconbase2d.assetbundle", SimpleLoadDataType.prefabAssetBundle, onloaded, null); }