Ejemplo n.º 1
0
    public static AssetManagerRequest LoadAsync <T>(String name) where T : UnityEngine.Object
    {
        //if (!name.EndsWith(".mes"))
        //{
        //    Log.Message(typeof(T).Name + ": " + name);
        //    Log.Message(Environment.StackTrace);
        //}

        if (AssetManagerForObb.IsUseOBB)
        {
            return(AssetManagerForObb.LoadAsync <T>(name));
        }

        if (!UseBundles || AssetManagerUtil.IsEmbededAssets(name))
        {
            ResourceRequest resReq = Resources.LoadAsync <T>(name);
            if (resReq != null)
            {
                return(new AssetManagerRequest(resReq, null));
            }
        }

        String  belongingBundleFilename = AssetManagerUtil.GetBelongingBundleFilename(name);
        Boolean flag1 = AssetManagerUtil.CheckModuleBundleFromName(AssetManagerUtil.ModuleBundle.CommonAssets, name);

        if (!String.IsNullOrEmpty(belongingBundleFilename) && DictAssetBundleRefs.ContainsKey(belongingBundleFilename))
        {
            AssetBundleRef assetBundleRef = DictAssetBundleRefs[belongingBundleFilename];
            if (assetBundleRef.assetBundle != null)
            {
                String name1 = AssetManagerUtil.GetResourcesBasePath() + name + AssetManagerUtil.GetAssetExtension <T>(name);
                //Boolean flag2 = name.IndexOf("atlas_a", StringComparison.Ordinal) != -1;
                AssetBundleRequest assReq = assetBundleRef.assetBundle.LoadAssetAsync(name1);
                if (assReq != null)
                {
                    return(new AssetManagerRequest(null, assReq));
                }

                if (!flag1 && ForceUseBundles)
                {
                    //if (Application.platform != RuntimePlatform.Android && flag2)
                    //    return null;

                    return(null);
                }
            }
        }

        ResourceRequest resReq1 = Resources.LoadAsync <T>(name);

        if (resReq1 != null)
        {
            return(new AssetManagerRequest(resReq1, null));
        }

        return(null);
    }
Ejemplo n.º 2
0
    public static AssetManagerRequest LoadAsync <T>(String name) where T : UnityEngine.Object
    {
        if (AssetManagerForObb.IsUseOBB)
        {
            return(AssetManagerForObb.LoadAsync <T>(name));
        }
        if (!AssetManager.UseBundles || AssetManagerUtil.IsEmbededAssets(name))
        {
            ResourceRequest resourceRequest = Resources.LoadAsync <T>(name);
            if (resourceRequest != null)
            {
                return(new AssetManagerRequest(resourceRequest, (AssetBundleRequest)null));
            }
        }
        String  belongingBundleFilename = AssetManagerUtil.GetBelongingBundleFilename(name);
        Boolean flag = AssetManagerUtil.CheckModuleBundleFromName(AssetManagerUtil.ModuleBundle.CommonAssets, name);

        if (!String.IsNullOrEmpty(belongingBundleFilename) && AssetManager.DictAssetBundleRefs.ContainsKey(belongingBundleFilename))
        {
            AssetManager.AssetBundleRef assetBundleRef = AssetManager.DictAssetBundleRefs[belongingBundleFilename];
            if (assetBundleRef.assetBundle != (UnityEngine.Object)null)
            {
                String text = AssetManagerUtil.GetResourcesBasePath() + name;
                text += AssetManagerUtil.GetAssetExtension <T>(name);
                Boolean            flag2 = name.IndexOf("atlas_a") != -1;
                AssetBundleRequest assetBundleRequest = assetBundleRef.assetBundle.LoadAssetAsync(text);
                if (assetBundleRequest != null)
                {
                    return(new AssetManagerRequest((ResourceRequest)null, assetBundleRequest));
                }
                if (!flag && AssetManager.ForceUseBundles)
                {
                    if (Application.platform != RuntimePlatform.Android && flag2)
                    {
                        return((AssetManagerRequest)null);
                    }
                    return((AssetManagerRequest)null);
                }
            }
        }
        ResourceRequest resourceRequest2 = Resources.LoadAsync <T>(name);

        if (resourceRequest2 != null)
        {
            return(new AssetManagerRequest(resourceRequest2, (AssetBundleRequest)null));
        }
        return((AssetManagerRequest)null);
    }