'2018/04'에 해당되는 글 1건

  1. 2018/04/24 글뻥 Unity on Jenkins Step 1.
Create "Editor" folder on "Asset" folder first.
and make a "ProjectBuilder.cs" file in "Editor" folder.

* This script tested on Unity 2018

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.AcceptExternalModificationsToPlayer;
                    /*
                     BuildOptions.SymlinkLibraries |
                     BuildOptions.Development |
                     BuildOptions.ConnectWithProfiler |
                     BuildOptions.AllowDebugging |
                     BuildOptions.Development; 
                     */
 
        //PlayerSettings.iOS.sdkVersion = iOSSdkVersion.DeviceSDK; 
        //PlayerSettings.iOS.targetOSVersionString = "11.0";
        //PlayerSettings.statusBarHidden = true;
        //PlayerSettings.iOS.cameraUsageDescription = "ARMode";
 
         PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, ScriptingImplementation.IL2CPP);
         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();
   }

    static void GenericBuild(string[] scenes, string target_filename, BuildTargetGroup build_group, BuildTarget build_target, BuildOptions build_options)
    {
        EditorUserBuildSettings.SwitchActiveBuildTarget(build_group, build_target);
        UnityEditor.Build.Reporting.BuildReport res = BuildPipeline.BuildPlayer(scenes, target_filename, build_target, build_options);
    }
}


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

Next time, Continue.



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