예제 #1
0
        /// <summary>
        /// Initializes asset bundle namager and starts download of manifest asset bundle.
        /// Returns the manifest asset bundle downolad operation object.
        /// </summary>
        static public AssetBundleLoadManifestOperation Initialize()
        {
#if UNITY_EDITOR
            SimulateAssetBundleInEditor = false;
#endif
            return(Initialize(AssetsUtility.GetPlatformName()));
        }
예제 #2
0
        public static void BuildAllAssetBundles()
        {
            string assetBundleDirectory = "Assets/StreamingAssets/AssetBundle/" + AssetsUtility.GetPlatformName() + "/";

            //	BuildPipeline.BuildAssetBundles (assetBundleDirectory, BuildAssetBundleOptions.None, BuildTarget.StandaloneOSX);

            if (!Directory.Exists(assetBundleDirectory))
            {
                Directory.CreateDirectory(assetBundleDirectory);
            }


            //第一个参数获取的是AssetBundle存放的相对地址。
            BuildPipeline.BuildAssetBundles(
                assetBundleDirectory,
                BuildAssetBundleOptions.ChunkBasedCompression |
                BuildAssetBundleOptions.DeterministicAssetBundle | BuildAssetBundleOptions.ForceRebuildAssetBundle,
                target);

            AssetDatabase.Refresh();
            //BuildAssetBundleOptions.ForceRebuildAssetBundle
        }
예제 #3
0
        public static AssetBundle LoadAB(string abPath)
        {
            if (abDic.ContainsKey(abPath) == true)
            {
                return(abDic [abPath]);
            }
            if (manifest == null)
            {
                AssetBundle manifestBundle = AssetBundle.LoadFromFile(AssetsManager.ASSETBUNDLE_PATH +
                                                                      AssetsManager.ASSETBUNDLE_FILENAME + "/" + AssetsUtility.GetPlatformName());
                Debug.Log(AssetsManager.ASSETBUNDLE_PATH + AssetsManager.ASSETBUNDLE_FILENAME);
                manifest = (AssetBundleManifest)manifestBundle.LoadAsset("AssetBundleManifest");
            }
            if (manifest != null)
            {
                // 2.获取依赖文件列表
                string [] cubedepends = manifest.GetAllDependencies(abPath);

                for (int index = 0; index < cubedepends.Length; index++)
                {
                    //Debug.Log(cubedepends[index]);
                    // 3.加载所有的依赖资源
                    LoadAB(cubedepends [index]);
                }

                // 4.加载资源
                abDic [abPath] = AssetBundle.LoadFromFile(AssetsManager.ASSETBUNDLE_PATH + abPath);

                return(abDic [abPath]);
            }
            return(null);
        }