示例#1
0
        public static IRes Create(string assetName, string ownerBundleName, short assetType)
        {
            switch (assetType)
            {
            case ResType.AssetBundle:
                return(AssetBundleRes.Allocate(assetName));

            case ResType.ABAsset:
                return(AssetRes.Allocate(assetName, ownerBundleName));

            case ResType.ABScene:
                return(SceneRes.Allocate(assetName));

            case ResType.Internal:
                return(InternalRes.Allocate(assetName));

            case ResType.NetImageRes:
                return(NetImageRes.Allocate(assetName));

            case ResType.LocalImageRes:
                return(LocalImageRes.Allocate(assetName));

            default:
                Log.E("Invalid assetType :" + assetType);
                return(null);
            }
        }
示例#2
0
        public static IRes Create(ResSearchRule resSearchRule, short assetType)
        {
            switch (assetType)
            {
            case ResType.AssetBundle:
                return(AssetBundleRes.Allocate(resSearchRule.AssetName));

            case ResType.ABAsset:
                return(AssetRes.Allocate(resSearchRule.AssetName, resSearchRule.OwnerBundle));

            case ResType.ABScene:
                return(SceneRes.Allocate(resSearchRule.AssetName));

            case ResType.Internal:
                return(ResourcesRes.Allocate(resSearchRule.AssetName,
                                             resSearchRule.AssetName.StartsWith("resources://")
                            ? InternalResNamePrefixType.Url
                            : InternalResNamePrefixType.Folder));

            case ResType.NetImageRes:
                return(NetImageRes.Allocate(resSearchRule.AssetName));

            case ResType.LocalImageRes:
                return(LocalImageRes.Allocate(resSearchRule.AssetName));

            default:
                Log.E("Invalid assetType :" + assetType);
                return(null);
            }
        }
示例#3
0
 public override void Load()
 {
     base.Load();
     if (assetBundleRes == null)
     {
         assetBundleRes = ResMgr.GetAssetBundleRes(Application.streamingAssetsPath + "/AssetBundles/" + assetBundleName);
     }
     asset = (assetBundleRes.Asset as AssetBundle).LoadAsset(Name);
     if (asset == null)
     {
         Debug.LogErrorFormat("AssetBundle{0} do not contain asset{1}", assetBundleRes, asset);
     }
 }
示例#4
0
    public static AssetBundleRes GetAssetBundleRes(string assetName)
    {
        Res res = SharedLoadedReses.Find(loadedAsset => loadedAsset.Name == assetName);

        if (res != null)
        {
            res.Retain();
            return(res as AssetBundleRes);
        }

        res = new AssetBundleRes(assetName);
        res.Load();
        SharedLoadedReses.Add(res);
        res.Retain();

        return(res as AssetBundleRes);
    }
示例#5
0
        public static Res Create(string assetName, string assetBundleName)
        {
            Res res = null;

            if (assetBundleName != null)
            {
                res = new AssetRes(assetName, assetBundleName);
            }
            else if (assetName.StartsWith("resources://"))
            {
                res = new ResourcesRes(assetName);
            }
            else
            {
                res = new AssetBundleRes(assetName);
            }

            return(res);
        }
示例#6
0
        public void OnSyncLoadFinish(IResLoader loader, AssetBundleRes res)
        {
            //Log.W("OnSyncLoadFinish:AssetBundleRes:" + res.name);
            if (res.assetBundle == null)
            {
                return;
            }

            string[] assetNames = res.assetBundle.GetAllAssetNames();

            if (assetNames == null)
            {
                return;
            }

            for (int i = assetNames.Length - 1; i >= 0; --i)
            {
                loader.Add2Load(PathHelper.FullAssetPath2Name(assetNames[i]), null, false);
            }
        }
示例#7
0
        public override bool LoadSync()
        {
            if (!CheckLoadAble())
            {
                return(false);
            }

            if (string.IsNullOrEmpty(AssetBundleName))
            {
                return(false);
            }

            AssetBundleRes abR = ResMgr.Instance.GetRes <AssetBundleRes>(AssetBundleName);

            if (abR == null || abR.assetBundle == null)
            {
                Log.E("Failed to Load Asset, Not Find AssetBundleImage:" + abR);
                return(false);
            }


            State = ResState.Ready;
            return(true);
        }
 public virtual void OnAsyncLoadFinish(IResLoader loader, AssetBundleRes res)
 {
 }
示例#9
0
 public void OnSyncLoadFinish(IResLoader loader, AssetBundleRes res)
 {
 }