Exemple #1
0
        public AssetBundle LoadAsset(string assetName)
        {
            string assetBundleName = $"{MD5Util.ComputeMD5(assetName)}.unity3d";

            if (assetBundles.ContainsKey(assetName))
            {
                return((AssetBundle)assetBundles[assetBundleName]);
            }
            else
            {
                AssetBundle assetBundle  = AssetBundle.LoadFromFile($"{PathUtil.GetPath(PathType.PersistentDataPath, "Res", PathUtil.GetPlatformForAssetBundle())}/{assetBundleName}");
                string[]    dependencies = assetBundleManifest.GetAllDependencies(assetBundleName);
                foreach (string item in dependencies)
                {
                    assetBundles.Add(item, AssetBundle.LoadFromFile($"{PathUtil.GetPath(PathType.PersistentDataPath, "Res", PathUtil.GetPlatformForAssetBundle())}/{item}"));
                }
                assetBundles.Add(assetName, assetBundle);
                return(assetBundle);
            }
        }