Exemplo n.º 1
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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");
            }
        }