Created
April 23, 2024 02:54
-
-
Save camnewnham/94679e670189dfe781e4421c4277e2d2 to your computer and use it in GitHub Desktop.
Disable and re-enable ultraleap for Unity builds
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
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