Skip to content

Commit

Permalink
chore: add windows builder script for alttester
Browse files Browse the repository at this point in the history
  • Loading branch information
nattb8 committed Aug 6, 2024
1 parent 3e508fb commit e480804
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
60 changes: 60 additions & 0 deletions sample/Assets/Editor/WindowsBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#if UNITY_EDITOR_WIN

using AltTester.AltTesterUnitySDK.Editor;
using AltTester.AltTesterUnitySDK;
using System;
using System.IO;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;

public class WindowsBuildScript
{
static void BuildForAltTester()
{
try
{
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
buildPlayerOptions.scenes = new string[] {
"Assets/Scenes/SelectAuthMethod.unity",
"Assets/Scenes/UnauthenticatedScene.unity",
"Assets/Scenes/AuthenticatedScene.unity",
"Assets/Scenes/ZkEvmGetBalance.unity",
"Assets/Scenes/ZkEvmGetTransactionReceipt.unity",
"Assets/Scenes/ZkEvmSendTransaction.unity",
"Assets/Scenes/ImxNftTransfer.unity"
};

buildPlayerOptions.locationPathName = "Builds/Windows64/SampleApp.exe";
buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
buildPlayerOptions.options = BuildOptions.Development | BuildOptions.IncludeTestAssemblies | BuildOptions.AutoRunPlayer;

// Setup for AltTester
var buildTargetGroup = BuildTargetGroup.Standalone;
AltBuilder.AddAltTesterInScriptingDefineSymbolsGroup(buildTargetGroup);
if (buildTargetGroup == UnityEditor.BuildTargetGroup.Standalone)
AltBuilder.CreateJsonFileForInputMappingOfAxis();
var instrumentationSettings = new AltInstrumentationSettings();
AltBuilder.InsertAltInScene(buildPlayerOptions.scenes[0], instrumentationSettings);

BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
AltBuilder.RemoveAltTesterFromScriptingDefineSymbols(BuildTargetGroup.Standalone);

if (report.summary.result == BuildResult.Succeeded)
{
Debug.Log("Build succeeded: " + report.summary.totalSize + " bytes");
}
else
{
Debug.LogError("Build failed");
}

}
catch (Exception exception)
{
Debug.LogException(exception);
}
}
}

#endif
11 changes: 11 additions & 0 deletions sample/Assets/Editor/WindowsBuilder.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e480804

Please sign in to comment.