-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from guitarrapc/feature/dedicated
chore: Sandbox to support il2cpp / dedicated server build
- Loading branch information
Showing
69 changed files
with
17,886 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Sandbox.Unity/artifacts/ | ||
Sandbox.Unity/Library/ | ||
Sandbox.Unity/Logs/ | ||
Sandbox.Unity/Temp/ | ||
Sandbox.Unity/*.csproj | ||
Sandbox.Unity/*.sln | ||
artifacts/ | ||
Library/ | ||
Logs/ | ||
Temp/ | ||
*.csproj | ||
*.sln |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"version": "1.0", | ||
"components": [ | ||
"Microsoft.VisualStudio.Workload.ManagedGame" | ||
] | ||
} |
148 changes: 148 additions & 0 deletions
148
sandbox/Sandbox.Unity.IL2CPPDedicatedServer/Assets/Editor/BuildUnityMenu.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
using System.IO; | ||
using UnityEditor; | ||
using UnityEditor.Build; | ||
|
||
public class BuildUnityMenu | ||
{ | ||
private static readonly string[] scenes = new[] { "Assets/Scenes/SampleScene.unity" }; | ||
|
||
[MenuItem("MyTools/Build Windows IL2CPP Player")] | ||
public static void BuildWindowsIl2cppPlayer() | ||
{ | ||
var path = "artifacts/WindowsPlayer/Build.il2cpp-player.exe"; | ||
|
||
var buildPlayerOptions = new BuildPlayerOptions(); | ||
|
||
// Platform & Architecture | ||
buildPlayerOptions.target = BuildTarget.StandaloneWindows; | ||
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Player; | ||
|
||
// IL2CPP | ||
EnableIl2Cpp(NamedBuildTarget.Standalone); | ||
|
||
// Path and Scenes | ||
buildPlayerOptions.locationPathName = path; | ||
buildPlayerOptions.scenes = scenes; | ||
|
||
// Build | ||
BuildPipeline.BuildPlayer(buildPlayerOptions); | ||
|
||
// Cleanup | ||
CleanupDontship(path); | ||
} | ||
|
||
[MenuItem("MyTools/Build Windows IL2CPP DedicatedServer")] | ||
public static void BuildWindowsIl2cppServer() | ||
{ | ||
var path = "artifacts/WindowsServer/Build.il2cpp-server.exe"; | ||
|
||
var buildPlayerOptions = new BuildPlayerOptions(); | ||
|
||
// Platform & Architecture | ||
buildPlayerOptions.target = BuildTarget.StandaloneWindows; | ||
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server; | ||
|
||
// IL2CPP | ||
EnableIl2Cpp(NamedBuildTarget.Server); | ||
|
||
// Path and Scenes | ||
buildPlayerOptions.locationPathName = path; | ||
buildPlayerOptions.scenes = scenes; | ||
|
||
// Build | ||
BuildPipeline.BuildPlayer(buildPlayerOptions); | ||
|
||
// Cleanup | ||
CleanupDontship(path); | ||
} | ||
|
||
[MenuItem("MyTools/Build Linux IL2CPP Player")] | ||
public static void BuildLinuxIl2cppPlayer() | ||
{ | ||
var path = "artifacts/LinuxPlayer/Build.il2cpp-player.x86_64"; | ||
|
||
var buildPlayerOptions = new BuildPlayerOptions(); | ||
|
||
// Platform & Architecture | ||
buildPlayerOptions.target = BuildTarget.StandaloneLinux64; | ||
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Player; | ||
|
||
// IL2CPP | ||
EnableIl2Cpp(NamedBuildTarget.Standalone); | ||
|
||
// Path and Scenes | ||
buildPlayerOptions.locationPathName = path; | ||
buildPlayerOptions.scenes = scenes; | ||
|
||
// Build | ||
BuildPipeline.BuildPlayer(buildPlayerOptions); | ||
|
||
// Cleanup | ||
CleanupDontship(path); | ||
} | ||
|
||
[MenuItem("MyTools/Build Linux IL2CPP DedicatedServer")] | ||
public static void BuildLinuxIl2cppServer() | ||
{ | ||
var path = "artifacts/LinuxServer/Build.il2cpp-server.x86_64"; | ||
|
||
var buildPlayerOptions = new BuildPlayerOptions(); | ||
|
||
// Platform & Architecture | ||
buildPlayerOptions.target = BuildTarget.StandaloneLinux64; | ||
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server; | ||
|
||
// IL2CPP | ||
EnableIl2Cpp(NamedBuildTarget.Server); | ||
|
||
// Path and Scenes | ||
buildPlayerOptions.locationPathName = path; | ||
buildPlayerOptions.scenes = scenes; | ||
|
||
// Build | ||
BuildPipeline.BuildPlayer(buildPlayerOptions); | ||
|
||
// Cleanup | ||
CleanupDontship(path); | ||
} | ||
|
||
/// <summary> | ||
/// Enable IL2CPP ScriptingBackend | ||
/// </summary> | ||
/// <param name="buildTarget"></param> | ||
private static void EnableIl2Cpp(NamedBuildTarget buildTarget) | ||
{ | ||
// IL2CPP Code Generation = OptimizeSize => faster build than OptimizeSpeed | ||
PlayerSettings.SetScriptingBackend(buildTarget, ScriptingImplementation.IL2CPP); | ||
PlayerSettings.SetManagedStrippingLevel(buildTarget, ManagedStrippingLevel.Minimal); | ||
PlayerSettings.SetIl2CppCompilerConfiguration(buildTarget, Il2CppCompilerConfiguration.Debug); | ||
PlayerSettings.SetIl2CppCodeGeneration(buildTarget, Il2CppCodeGeneration.OptimizeSize); | ||
} | ||
|
||
/// <summary> | ||
/// Enable Mono ScriptingBackend | ||
/// </summary> | ||
/// <param name="buildTarget"></param> | ||
private static void EnableMono(NamedBuildTarget buildTarget) | ||
{ | ||
PlayerSettings.SetScriptingBackend(buildTarget, ScriptingImplementation.Mono2x); | ||
} | ||
|
||
/// <summary> | ||
/// Build Cleanup | ||
/// </summary> | ||
/// <param name="locationPathName"></param> | ||
private static void CleanupDontship(string locationPathName) | ||
{ | ||
// Cleanup IL2CPP debugger information directories | ||
var dir = Path.GetDirectoryName(locationPathName); | ||
var fileName = Path.GetFileNameWithoutExtension(locationPathName); | ||
var removeTargets = new[] { $"{dir}/{fileName}_BackUpThisFolder_ButDontShipItWithYourGame" }; | ||
|
||
foreach (var target in removeTargets) | ||
{ | ||
if (!Directory.Exists(target)) continue; | ||
Directory.Delete(target, true); | ||
} | ||
} | ||
} |
Oops, something went wrong.