Esempio n. 1
0
        /// <summary>
        /// 取得保存 目的地址
        /// </summary>
        /// <param name="type"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        private static string GetSavePath(EnumBuidleType type, BuildTarget target)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            switch (target)
            {
            case BuildTarget.StandaloneWindows:
            case BuildTarget.StandaloneWindows64:
                sb.Append(type.ToString());
                sb.Append("\\");
                sb.Append(Application.productName);
                sb.Append(".");
                sb.Append(CURRENT_VERSION);
                sb.Append(".");
                sb.Append(type.ToString());
                sb.Append(".exe");
                break;

            default:
                break;
            }
            return(sb.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// 通用打包函数
        /// </summary>
        /// <param name="buidleType"></param>
        /// <param name="type"></param>
        /// <param name="BuildName"></param>
        /// <param name="isClearPath"></param>
        private static void BuidleByType(EnumBuidleType buidleType, BuildTarget type, bool isClearPath = false)
        {
            //取得保存路径
            string savePath = GetTargetDirPath();
            //取得保存exe路径
            string saveExEPath = savePath + GetSavePath(buidleType, type);

            savePath = savePath + buidleType.ToString();

            if (isClearPath)
            {
                //清空目录
                ClearPath(saveExEPath);
            }

            //删除已经存在的游戏包
            if (System.IO.File.Exists(saveExEPath))
            {
                System.IO.File.Delete(saveExEPath);
            }

            //创建目录
            MakePath(saveExEPath);
            UnityEngine.Debug.Log("保存路径" + saveExEPath);


            //UnityEngine.Debug.Log("TYPE" + (type == BuildTarget.iOS));

            //设置预先配置信息
            PerSetting(buidleType);

            ////刷新Unity保存
            //AssetDatabase.Refresh();
            //设置宏定义
            SetBuildingDefine(GetBuildTargetGroup(type), GetDefine(buidleType));

            //取得打包Options
            BuildPlayerOptions option = GetBuildPlayerOptions(type, saveExEPath);

            //打包
            BuildForPlatform(option, savePath);
        }