Beispiel #1
0
    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);
        }
    }
Beispiel #2
0
 public override void OnAdd(SceneObjectBaseComponent c)
 {
     base.OnAdd(c);
     modelComponent = (ModelComponent)c;
     u3dTransComp   = U3DSceneObject.GetComponent <U3DTransformComponent>();
     AssetResources.LoadAsset(modelComponent.RePath, OnLoadedRes);
 }
Beispiel #3
0
    //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);
    }
Beispiel #4
0
 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));
     }
 }
Beispiel #5
0
        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;
        }
Beispiel #6
0
 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);
     }
 }
Beispiel #7
0
        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();
            }
        }
Beispiel #8
0
    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);
        }
    }
Beispiel #9
0
 // 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);
     }
 }
Beispiel #10
0
    public static void Init()
    {
        var txt = AssetResources.LoadAssetImmediatly("armyconf.bytes") as TextAsset;

        Deserialize(txt.bytes);
    }
Beispiel #11
0
 protected override void OnStart()
 {
     _guiseState = State as GuiseState;
     AssetResources.LoadAsset(_guiseState.Path, OnLoad);
 }
Beispiel #12
0
 public override void Execute(U3DSceneObject sender, U3DSceneObject receiver, object data)
 {
     _playFxAction = this.Action as PlayFXAction;
     _sender = sender;
     AssetResources.LoadAsset(_playFxAction.FXName, OnLoadRes);
 }