private void ShowUI(object sender, EventMsg e) { var msg = e as EventThreeArgs <string, Type, object>; string uiName = msg.value1; Type t = msg.value2; object para = msg.value3; bool isLoading = false; for (int i = 0; i < _waitingForLoadView.Count; i++) { if (_waitingForLoadView[i].UiName.Equals(uiName)) { isLoading = true; break; } } if (!isLoading) { _waitingForLoadView.Add(new PendingViewInfo() { UiName = uiName, UiType = t, Param = para }); AssetResources.LoadAsset(uiName, OnLoadUI); } }
public override void OnAdd(SceneObjectBaseComponent c) { base.OnAdd(c); modelComponent = (ModelComponent)c; u3dTransComp = U3DSceneObject.GetComponent <U3DTransformComponent>(); AssetResources.LoadAsset(modelComponent.RePath, OnLoadedRes); }
//System.Diagnostics.Stopwatch sw = new Stopwatch(); //sw.Start(); IEnumerator LoadMainAsset() { var asyn = AssetBundle.LoadFromFileAsync(AssetResources.GetAssetPath(BundleName)); yield return(asyn.assetBundle); var assetsReq = asyn.assetBundle.LoadAllAssetsAsync(); yield return(assetsReq); AssetResources.RemoveFinishedLoader(this, BundleName, assetsReq.allAssets, asyn.assetBundle); Pool.SP.Recycle(this); }
public static Dictionary <int, string> LoadIndexFile(string fpath) { if (Application.isPlaying) { var text = AssetResources.LoadAssetImmediatly(fpath) as TextAsset; return(Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <int, string> >(text.text, settings)); } else { var text = Utility.ReadStringFromAbsolutePath(GetRequiredConfigsPath() + fpath); return(Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <int, string> >(text, settings)); } }
public override void OnAdd() { base.OnAdd(); var bt = AssetResources.LoadAssetImmediatly(BtPath) as BTAsset; m_behaviourTree = bt; m_blackboard = new Blackboard(); if (m_behaviourTree != null) { m_btInstance = m_behaviourTree.CreateRuntimeTree(); } m_timeElapsedSinceLastUpdate = 0.0f; m_isRunning = true; }
public static T GetTimelineGroup <T>(string path) where T : TimeLineGroup { if (Application.isPlaying) { var text = AssetResources.LoadAssetImmediatly(path) as TextAsset; T t = Newtonsoft.Json.JsonConvert.DeserializeObject <T>(text.text, settings); return(t); } else { string text = Utility.ReadStringFromAbsolutePath(GetRequiredConfigsPath() + path); T t = Newtonsoft.Json.JsonConvert.DeserializeObject <T>(text, settings); return(t); } }
IEnumerator LoadHashFileFromServer() { UnityWebRequest www = UnityWebRequest.Get("http://47.94.204.158/AB/assetBundleHash.txt"); yield return(www.Send()); if (www.isError) { DLog.Log(www.error); } else { // Show results as text _needDownLoadList.Clear(); // System.Diagnostics.Stopwatch sw = new Stopwatch(); var remoteBundleHash = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(www.downloadHandler.text); var localBundleHash = AssetResources.LoadBundleHash(); foreach (var bh in remoteBundleHash) { string hash; if (localBundleHash.TryGetValue(bh.Key, out hash)) { if (!hash.Equals(bh.Value)) { _needDownLoadList.Add(bh.Key); } } else { _needDownLoadList.Add(bh.Key); } } for (int i = 0; i < _needDownLoadList.Count; i++) { DLog.Log("Start Download " + _needDownLoadList[i]); Main.SP.StartCoroutine(DownLoadAssetBundle(_needDownLoadList[i], (s, bytes) => { _needDownLoadList.Remove(s); DLog.Log(s + " Download Finish"); SaveToPersistentPath(s, bytes); })); } SaveToPersistentPath("assetBundleHash.txt", www.downloadHandler.data); www.Dispose(); } }
private static void LoadImediately(string bundleName) { var dependencies = AssetResources.Manifest.GetDirectDependencies(bundleName); if (dependencies.Length > 0) { for (int i = dependencies.Length - 1; i >= 0; i--) { LoadImediately(dependencies[i]); } } if (!BundleNameAssets.ContainsKey(bundleName)) { var bundle = AssetBundle.LoadFromFile(AssetResources.GetAssetPath(bundleName)); var assets = bundle.LoadAllAssets(); InsertAssetToMap(bundleName, assets, bundle); } }
// private bool public void Start(string bundleName) { this.BundleName = bundleName; LoadCoroutine = LoadMainAsset(); dependencies = AssetResources.Manifest.GetAllDependencies(bundleName); AssetResources.AddLoadingLoader(this); if (dependencies.Length > 0) { depenObjs = new Object[dependencies.Length]; for (int i = dependencies.Length - 1; i >= 0; i--) { AssetResources.LoadBundle(dependencies[i], OnDependencyLoadFinish); } } else { Main.SP.StartCoroutine(LoadCoroutine); } }
public static void Init() { var txt = AssetResources.LoadAssetImmediatly("armyconf.bytes") as TextAsset; Deserialize(txt.bytes); }
protected override void OnStart() { _guiseState = State as GuiseState; AssetResources.LoadAsset(_guiseState.Path, OnLoad); }
public override void Execute(U3DSceneObject sender, U3DSceneObject receiver, object data) { _playFxAction = this.Action as PlayFXAction; _sender = sender; AssetResources.LoadAsset(_playFxAction.FXName, OnLoadRes); }