Create "Editor" folder on "Asset" folder first.
and make a "ProjectBuilder.cs" file in "Editor" folder.

using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;

class ProjectBuilder {
    static string[] SCENES = FindEnabledEditorScenes();
    static string APP_NAME = "Your Project name";
    static string TARGET_DIR = "build";

    [MenuItem ("ForYou/CI/Build IOS")]
    staticvoidPerformiOSBuild ()
    {
        BuildOptions opt = BuildOptions.Il2CPP |
        BuildOptions.AcceptExternalModificationsToPlayer;
         /*
             BuildOptions.SymlinkLibraries |
            BuildOptions.Development |
            BuildOptions.ConnectWithProfiler |
            BuildOptions.AllowDebugging |
            BuildOptions.Development;
         */
        
        //If you want to change attribute by script, use it.
        //PlayerSettings.iOS.sdkVersion = iOSSdkVersion.DeviceSDK;
        //PlayerSettings.iOS.targetOSVersionString = "11.0";
        //PlayerSettings.statusBarHidden = true;
        //PlayerSettings.iOS.cameraUsageDescription = "ARMode";

        char sep = Path.DirectorySeparatorChar;
        string buildDirectory = Path.GetFullPath(".") + sep + TARGET_DIR;
        Directory.CreateDirectory(buildDirectory);

        string BUILD_TARGET_PATH = buildDirectory + "/ios";
        Directory.CreateDirectory(BUILD_TARGET_PATH);

        GenericBuild(SCENES, BUILD_TARGET_PATH, BuildTargetGroup.iOS, BuildTarget.iOS, opt);
    }

    [MenuItem ("ForYou/CI/Build Android")]
    staticvoidPerformAndroidBuild ()
    {
        string target_filename = APP_NAME + ".apk";
        GenericBuild(SCENES, target_filename, BuildTargetGroup.Android, BuildTarget.Android ,BuildOptions.None);
    }
    
    [MenuItem ("ForYou/CI/Build Window")]
    static void PerformWindowsBuild () {
        string target_filename = APP_NAME + ".exe";
        GenericBuild(SCENES, target_filename, BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows, BuildOptions.None);
    }

    [MenuItem ("ForYou/CI/Build Mac")]
    static void PerformMacBuild () {
        string target_filename = APP_NAME + ".app";
        GenericBuild(SCENES, target_filename, BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX, BuildOptions.None);
    }

   private static string[] FindEnabledEditorScenes() {
      List<string> EditorScenes = new List<string>();
      foreach(EditorBuildSettingsScene scene in EditorBuildSettings.scenes) {
         if (!scene.enabled) continue;
         EditorScenes.Add(scene.path);
      }
      return EditorScenes.ToArray();
   }

    staticvoidGenericBuild(string[] scenes, string target_filename, BuildTargetGroup build_group, BuildTarget build_target, BuildOptions build_options)
    {
        EditorUserBuildSettings.SwitchActiveBuildTarget(build_group, build_target);
        string res = BuildPipeline.BuildPlayer(scenes, target_filename, build_target, build_options);
        if (res.Length > 0) {
            thrownewException("BuildPlayer failure: " + res);
        }
    }
}


You could copy & paste it. and Test it on Unity3d Editor.

Next time, Continue.



2018/04/24 08:22 2018/04/24 08:22

트랙백 주소 :: 이 글에는 트랙백을 보낼 수 없습니다