Exemplo n.º 1
0
    public override int LoadAsync(IAssetLoader loader, ResourceMgr.AssetLoadCompleted OnAssetLoadCompleted)
    {
        if (Asset == null)
        {
            ABAssetLoader abLoader = loader as ABAssetLoader;
            if (abLoader == null)
            {
                OnAssetLoadCompleted(0, null);
                return(0);
            }
            string sABPath = abLoader.GetAssetBundleFromAsset(Path);
            if (string.IsNullOrEmpty(sABPath))
            {
                return(0);
            }

            m_ABInfo = AssetCacheMgr.Instance.GetABCache(sABPath);
            AssetLoadCompletedEvent += OnAssetLoadCompleted;
            AssetLoadCompletedEvent += OnLoadAssetCompeleted;
            m_ABInfo.LoadABAsync(true, null, OnLoadABCompeleted);
            return(0);
        }
        else
        {
            OnAssetLoadCompleted.Invoke(0, Asset);
            return(0);
        }
    }
Exemplo n.º 2
0
    public int LoadAssetAsync <T>(string sPath, ResourceMgr.AssetLoadCompleted OnAssetLoadCompleted) where T : UnityEngine.Object
    {
        ResourceRequest req = Resources.LoadAsync <T>(StringUtils.WithoutExtension(sPath));

        req.completed += (ao) => {
            ResourceRequest    resourceRequest = ao as ResourceRequest;
            UnityEngine.Object @object         = null;
            if (resourceRequest != null)
            {
                @object = resourceRequest.asset;
            }
            OnAssetLoadCompleted.Invoke(req.GetHashCode(), @object);
        };
        return(req.GetHashCode());
    }