XimmerseUnityXRInitialize.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #if UNITY_EDITOR
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEditor;
  6. namespace Ximmerse.XR.LegacySDKs
  7. {
  8. /// <summary>
  9. /// Ximmerse unity XR initializer.
  10. /// </summary>
  11. public static class XimmerseUnityXRInitialize
  12. {
  13. [MenuItem("Ximmerse XR SDK/Initialize XR SDK")]
  14. public static void InitializeXRSDK ()
  15. {
  16. SetupAndroidSetting();
  17. }
  18. static void SetupAndroidSetting()
  19. {
  20. //Set multi-thread = false
  21. PlayerSettings.SetMobileMTRendering(BuildTargetGroup.Android, false);
  22. PlayerSettings.defaultInterfaceOrientation = UIOrientation.LandscapeLeft;
  23. PlayerSettings.graphicsJobMode = GraphicsJobMode.Legacy;
  24. //Disable GPU skinning to save GPU power
  25. PlayerSettings.gpuSkinning = false;
  26. PlayerSettings.colorSpace = ColorSpace.Linear;
  27. PlayerSettings.openGLRequireES31 = true;
  28. PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false);
  29. PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new UnityEngine.Rendering.GraphicsDeviceType[] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 });
  30. PlayerSettings.Android.forceSDCardPermission = true;
  31. QualitySettings.vSyncCount = 0;//No vsync
  32. //IL2CPP and 64bit:
  33. PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
  34. PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
  35. //Android API level :
  36. PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel26;
  37. PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto;
  38. AssetDatabase.SaveAssets();
  39. AssetDatabase.Refresh();
  40. }
  41. }
  42. }
  43. #endif