Exemplo n.º 1
0
        public static void BuildPlayerWithoutAssetBundles()
        {
            var outputPath = UnityEditor.EditorUtility.SaveFolderPanel("Choose Location of the Built Game", "", "");

            if (outputPath.Length == 0)
            {
                return;
            }
            string[] levels = EditorUtil.GetScenesInBuildSetting();
            if (levels.Length == 0)
            {
                return;
            }
            string targetName = "/" + EditorUtil.GetBuildTargetName(EditorUserBuildSettings.activeBuildTarget);

            if (targetName == null)
            {
                return;
            }
#if UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0
            BuildOptions option = EditorUserBuildSettings.development ? BuildOptions.Development : BuildOptions.None;
            BuildPipeline.BuildPlayer(levels, outputPath + targetName, EditorUserBuildSettings.activeBuildTarget, option);
#else
            BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
            buildPlayerOptions.scenes                  = levels;
            buildPlayerOptions.locationPathName        = outputPath + targetName;
            buildPlayerOptions.assetBundleManifestPath = ABBuild.GetAssetBundleManifestFilePath();
            buildPlayerOptions.target                  = EditorUserBuildSettings.activeBuildTarget;
            buildPlayerOptions.options                 = EditorUserBuildSettings.development ? BuildOptions.Development : BuildOptions.None;
            BuildPipeline.BuildPlayer(buildPlayerOptions);
#endif
        }
Exemplo n.º 2
0
        public static void BuildStandalonePlayer()
        {
            var outputPath = EditorUtility.SaveFolderPanel("Choose Location of the Built Game", "", "");

            if (outputPath.Length == 0)
            {
                return;
            }
            string[] levels = EditorUtil.GetScenesInBuildSetting();
            if (levels.Length == 0)
            {
                return;
            }
            string targetName = "/" + EditorUtil.GetBuildTargetName(EditorUserBuildSettings.activeBuildTarget);

            if (targetName == null)
            {
                return;
            }
            ABBuild.CopyAssetBundlesTo(Path.Combine(Application.streamingAssetsPath, ABTool.AssetBundleOutPutPath));
            AssetDatabase.Refresh();
#if UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0
            BuildOptions option = EditorUserBuildSettings.development ? BuildOptions.Development : BuildOptions.None;
            BuildPipeline.BuildPlayer(levels, outputPath + targetName, EditorUserBuildSettings.activeBuildTarget, option);
#else
            BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
            buildPlayerOptions.scenes                  = levels;
            buildPlayerOptions.locationPathName        = outputPath + targetName;
            buildPlayerOptions.assetBundleManifestPath = ABBuild.GetAssetBundleManifestFilePath();
            buildPlayerOptions.target                  = EditorUserBuildSettings.activeBuildTarget;
            buildPlayerOptions.options                 = EditorUserBuildSettings.development ? BuildOptions.Development : BuildOptions.None;
            BuildPipeline.BuildPlayer(buildPlayerOptions);
#endif
        }