agones.dev/agones@v1.53.0/examples/unity-simple/Assets/Scripts/Editor/BatchBuild.cs (about)

     1  // Copyright 2019 Google LLC
     2  // All Rights Reserved.
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  
    16  using System.IO;
    17  using UnityEditor;
    18  
    19  namespace AgonesExample.Editor
    20  {
    21      public class BatchBuild
    22      {
    23          [MenuItem("Build Tool/Build Server")]
    24          public static void BuildServer()
    25          {
    26              string[] scenes = new[] { "Assets/Scenes/AgonesUnitySimple.unity" };
    27              string dir = "Builds/Server";
    28  
    29              Directory.CreateDirectory(dir);
    30  
    31              BuildPlayerOptions option = new BuildPlayerOptions
    32              {
    33                  scenes = scenes,
    34                  locationPathName = dir + "/UnitySimpleServer.x86_64",
    35                  target = BuildTarget.StandaloneLinux64,
    36                  options = BuildOptions.EnableHeadlessMode
    37              };
    38              BuildPipeline.BuildPlayer(option);
    39          }
    40  
    41          [MenuItem("Build Tool/Build Client")]
    42          public static void BuildClient()
    43          {
    44              string[] scenes = new[] { "Assets/Scenes/AgonesUnitySimple.unity" };
    45              string dir = "Builds/Client";
    46  
    47              Directory.CreateDirectory(dir);
    48  
    49              var target = BuildTarget.StandaloneWindows64;
    50  #if UNITY_EDITOR_OSX
    51              target = BuildTarget.StandaloneOSX;
    52  #elif !UNITY_EDITOR_WIN && !UNITY_EDITOR_OSX
    53              target = BuildTarget.StandaloneLinux64;
    54  #endif
    55              BuildPlayerOptions option = new BuildPlayerOptions
    56              {
    57                  scenes = scenes,
    58                  locationPathName = dir + "/UnitySimpleClient.exe",
    59                  target = target,
    60                  options = BuildOptions.None
    61              };
    62              BuildPipeline.BuildPlayer(option);
    63          }
    64      }
    65  }
    66