public static void BuildAssetBundlesForiOS() { try { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS); AssetBundlesBuildOptions options = GenerateBuildOptions(); ArrangeAssetBundleDirectory(options.ClearFolder); ApplyAssetLabels(); GenerateAssetBundleInfomationFile(); BuildPipeline.BuildAssetBundles(AssetBundlesOutputPath, AssetBundleOptions(options), BuildTarget.iOS); MakeBundleSizeFile(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); if (options.CopyToStreamingAssets) { EditorUtilities.DirectoryCopy(AssetBundlesOutputPath, Application.streamingAssetsPath); } } catch (System.Exception e) { Debug.LogError(e.Message); MakeErrorFile(e.Message); } }
private static bool OpenAssetBundleOptions() { TextAsset jsonText = UnityEngine.Resources.Load(AssetBundleOptionsFileName) as TextAsset; if (jsonText == null) { Options = new AssetBundlesBuildOptions(); WriteInfosFile(); AssetDatabase.Refresh(); jsonText = UnityEngine.Resources.Load(AssetBundleOptionsFileName) as TextAsset; } Options = JsonUtility.FromJson <AssetBundlesBuildOptions>(jsonText.text); if (Options == null) { EditorUtility.DisplayDialog("Error", "There is a problem with AssetBundleOptions.", "ok"); return(false); } return(true); }
private static BuildAssetBundleOptions AssetBundleOptions(AssetBundlesBuildOptions options) { BuildAssetBundleOptions resultOptions = ConvertCompressOption(options.CompressOption); if (options.StrictMode) { resultOptions = resultOptions | BuildAssetBundleOptions.StrictMode; } if (options.ForceRebuildAssetBundle) { resultOptions = resultOptions | BuildAssetBundleOptions.ForceRebuildAssetBundle; } return(resultOptions); }
private static AssetBundlesBuildOptions GenerateBuildOptions() { TextAsset jsonText = UnityEngine.Resources.Load(AssetBundleOptionsFileName) as TextAsset; if (jsonText != null) { AssetBundlesBuildOptions GeneratedOptions = JsonUtility.FromJson <AssetBundlesBuildOptions>(jsonText.text); if (GeneratedOptions != null) { return(GeneratedOptions); } else { throw new System.Exception("BuildPlayer Exception : AssetBundlesBuildOptions is Null"); } } else { throw new System.Exception("BuildPlayer Exception : Make a AssetBundlesBuildOptions first"); } }