Exemplo n.º 1
0
        public static string BuildAssetBundles(bool buildToStreamingAssets)
        {
            var assetBundlePath = buildToStreamingAssets ? GetAssetBundleStreamingAssetsPath() : GetAssetBundlePath();

            // creating the platform directory inside the asset bundle directory
            var assetBundlePlatformPath = Path.Combine(assetBundlePath, AssetBundleUtility.GetPlatformName()).Replace("\\", "/");

            Directory.CreateDirectory(assetBundlePlatformPath);

            // building asset bundles
            BuildAssetBundleOptions options = GetAssetBundleBuildOptions();

            BuildPipeline.BuildAssetBundles(assetBundlePlatformPath, options, EditorUserBuildSettings.activeBuildTarget);

            // no need to import asset bundles if they don't live in the assets folder
            if (buildToStreamingAssets)
            {
                // making sure all those asset bundles get imported and unity is aware of them
                foreach (string assetBundleFile in Directory.GetFiles(assetBundlePath, "*", SearchOption.AllDirectories))
                {
                    var assetPath = assetBundleFile.Replace("\\", "/");

                    if (assetPath.EndsWith(".meta"))
                    {
                        continue;
                    }

                    AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
                }

                AssetDatabase.Refresh();
            }

            return(assetBundlePath);
        }
Exemplo n.º 2
0
 private static void SetSourceAssetBundleURL(string absolutePath)
 {
     // making sure everything is a "/" and the base url ends with a "/"
     absolutePath       = absolutePath.Replace("\\", "/").AppendIfDoesntExist("/");
     BaseDownloadingURL = absolutePath + AssetBundleUtility.GetPlatformName() + "/";
 }
Exemplo n.º 3
0
 // Initializes asset bundle namager and starts download of manifest asset bundle.
 // Returns the manifest asset bundle downolad operation object.
 public static AssetBundleLoadManifestOperation Initialize()
 {
     return(Initialize(AssetBundleUtility.GetPlatformName()));
 }