Skip to content

Instantly share code, notes, and snippets.

@camnewnham
Created April 23, 2024 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camnewnham/94679e670189dfe781e4421c4277e2d2 to your computer and use it in GitHub Desktop.
Save camnewnham/94679e670189dfe781e4421c4277e2d2 to your computer and use it in GitHub Desktop.
Disable and re-enable ultraleap for Unity builds
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
namespace MyApp
{
/// <summary>
/// Disables the Ultraleap provider at build time
/// </summary>
public class UltraleapPreprocessor : IPreprocessBuildWithReport
{
internal static bool WasUltraleapEnabledBeforeBuild = false;
public int callbackOrder => 0;
public void OnPreprocessBuild(BuildReport report)
{
WasUltraleapEnabledBeforeBuild = Leap.Unity.UltraleapSettings.Instance.leapSubsystemEnabled;
if (WasUltraleapEnabledBeforeBuild)
{
Debug.Log("Disabling Ultraleap subsystem for build.");
Leap.Unity.UltraleapSettings.Instance.leapSubsystemEnabled = false;
}
}
}
public class UltraleapPostProcessor : IPostprocessBuildWithReport
{
public int callbackOrder => 0;
public void OnPostprocessBuild(BuildReport report)
{
if (UltraleapPreprocessor.WasUltraleapEnabledBeforeBuild)
{
Debug.Log("Re-enabling ultraleap subsystem post-build.");
Leap.Unity.UltraleapSettings.Instance.leapSubsystemEnabled = true;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment