Example #1
0
 public Object Load <T>(string path, AssetType type, out uint hash) where T : Object
 {
     hash = XCommon.singleton.XHash(path + type);
     if (map.ContainsKey(hash))
     {
         map[hash].ref_cnt++;
         return(map[hash].obt);
     }
     else
     {
         T     obt     = Resources.Load <T>(path);
         bool  isClone = XResources.IsCloneAsset <T>();
         Asset asset   = new Asset {
             obt = obt, ref_cnt = 1, is_clone_asset = isClone
         };
         map.Add(hash, asset);
         return(obt);
     }
 }
Example #2
0
    public void AsynLoad <T>(string path, AssetType type, System.Action <Object> cb) where T : Object
    {
        uint      hash = XCommon.singleton.XHash(path + type);
        AsynAsset asset;

        if (map.ContainsKey(hash) && map[hash].obt != null) //已经加载的 计数器加一
        {
            map[hash].ref_cnt++;
            if (map[hash].is_clone_asset)
            {
                GameObject go = GameObject.Instantiate(map[hash].obt) as GameObject;
                XResources.SetAsynAssetIndex(go.GetInstanceID(), hash);
                cb(go);
            }
            else
            {
                cb(map[hash].obt);
                XResources.SetAsynAssetIndex(map[hash].obt.GetInstanceID(), hash);
            }
        }
        else if (IsAsynLoading(path, out asset)) //已正在加载的 回调cache
        {
            asset.cb.Add(cb);
        }
        else //没有加载的 开始加载
        {
            AsynAsset node = new AsynAsset();
            node.path           = path;
            node.type           = type;
            node.is_clone_asset = XResources.IsCloneAsset <T>();
            node.request        = Resources.LoadAsync <T>(path);
            node.cb             = new List <System.Action <Object> >();
            node.cb.Add(cb);
            asyn_list.Add(node);
            asyn_loading_cnt = asyn_list.Count;
        }
    }
Example #3
0
 public UnityEngine.Object Load <T>()
 {
     isCloneAsset = XResources.IsCloneAsset <T>();
     return(InnerLoad());
 }
Example #4
0
 public void LoadAsyn <T>(Action <UnityEngine.Object> cb)
 {
     isCloneAsset = XResources.IsCloneAsset <T>();
     loadCB       = cb;
     InnerLoad();
 }