Beispiel #1
0
        /// <summary>
        /// 生成目标工程
        /// </summary>
        private static void GenerateProject()
        {
            BuildPlayerOptions options = new BuildPlayerOptions();

            options.target = EditorBaseUtil.GetBuildTarget();
            string exportPath = EditorPathUtil.GetExportProjectPath();
            string folderPath = Path.GetDirectoryName(exportPath);

            if (Directory.Exists(folderPath))
            {
                FileUtil.DeleteFileOrDirectory(folderPath);
            }
            options.locationPathName = exportPath;
            options.options          = BuildOptions.AcceptExternalModificationsToPlayer;
            BuildReport report = BuildPipeline.BuildPlayer(options);

            if (report.summary.result == BuildResult.Succeeded)
            {
                Debug.LogFormat("Export project path={0} success!", exportPath);
            }
            else
            {
                Debug.LogFormat("Export project path={0} Failure!", exportPath);
            }
        }
    /// <summary>
    /// 获取导出项目路径
    /// </summary>
    /// <returns></returns>
    public static string GetExportProjectPath()
    {
        BuildTarget target = EditorBaseUtil.GetBuildTarget();

        if (target == BuildTarget.StandaloneWindows || target == BuildTarget.StandaloneWindows64)
        {
            return(string.Format("{0}/app/{1}.exe", RootPath, PlayerSettings.productName));
        }
        else if (target == BuildTarget.StandaloneOSX)
        {
            return(string.Format("{0}/app/{1}.app", RootPath, PlayerSettings.productName));
        }
        else
        {
            return(string.Format("{0}/app/{1}", RootPath, PlayerSettings.productName));
        }
    }