Sha256: 13b250eefefc398e48cb651cd3b94b517770fe336e2f6bbbc48cf6511aabd058

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using System.IO;
using System;

namespace U3d {
  class EditorRun {
    [MenuItem ("U3d/Example/Build")]
    static void Build() {
      Debug.Log("Building Example2");

      BuildTarget Target;
#if UNITY_2017_3_OR_NEWER
      Target = BuildTarget.StandaloneOSX;
#else
      Target = BuildTarget.StandaloneOSXIntel64;
#endif      

      BuildPlayer(EditorBuildSettings.scenes, "target/Example2.app", Target, BuildOptions.None);
    }

    private static void BuildPlayer(EditorBuildSettingsScene[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options) {
      FileSystemUtil.EnsureParentExists(target_dir);
      string res = BuildPipeline.BuildPlayer(scenes, target_dir, build_target, build_options);
      if (res.Length > 0) {
        throw new Exception("BuildPlayer failure: " + res);
      }      
    }
  }

  class FileSystemUtil {
    public static void EnsureParentExists(string target_dir) {
      DirectoryInfo parent = Directory.GetParent(target_dir);
      if (!parent.Exists) {
        Directory.CreateDirectory(parent.FullName);
      }
    }    
  }
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
u3d-1.3.4 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.3.3 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.3.2 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.3.1 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.3.0 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.2.3 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.2.2 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.2.1 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.2.0 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.1.5 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.1.4 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.1.3 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.1.2 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.1.1 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.1.0 examples/Example2/Assets/Editor/EditorRun.cs
u3d-1.0.21 examples/Example2/Assets/Editor/EditorRun.cs