123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Reflection;
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.XR;
- using UnityEditor.PackageManager;
- using UnityEditor.PackageManager.Requests;
- using System.Threading;
- using System.Collections;
- using static UnityEditor.PlayerSettings;
- public class GHZGlassSDKSettings
- {
- [MenuItem("GHZ/GHZGlassSDK/SDK_DreamGlass")]
- public static void DreamGlassInit()
- {
- Debug.Log("DreamGlassInit");
- DreamGlassSet();
- PlayerSet("DreamGlass");
- }
- [MenuItem("GHZ/GHZGlassSDK/SDK_Phone")]
- public static void PhoneInit()
- {
- Debug.Log("Phone");
- PhoneSet();
- PlayerSet("Phone");
- }
- [MenuItem("GHZ/GHZGlassSDK/SDK_Rhinox")]
- public static void RhinoxInit()
- {
- Debug.Log("RhinoxInit");
- RhinoxSet();
- PlayerSet("Rhinox");
- }
- [MenuItem("GHZ/GHZGlassSDK/SDK_Nreal")]
- public static void NrealInit()
- {
- Debug.Log("NrealInit");
- NrealSet();
- PlayerSet("Nreal");
- }
- [MenuItem("GHZ/GHZGlassSDK/SDK_A01")]
- public static void A01Init()
- {
- Debug.Log("A01Init");
- A01Set();
- PlayerSet("A01");
- }
- static void DreamGlassSet()
- {
- PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel26;
- PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto;
- PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Android, ApiCompatibilityLevel.NET_4_6);
- PlayerSettings.SetMobileMTRendering(BuildTargetGroup.Android, true);
- PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false);
- PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new UnityEngine.Rendering.GraphicsDeviceType[1] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 });
- PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
- Android.targetArchitectures = AndroidArchitecture.ARMv7;
- PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait;
- EditorSettings.serializationMode = SerializationMode.ForceText;
- Type playerSettingsType = typeof(PlayerSettings);
- MethodInfo method = playerSettingsType.GetMethod("SetBatchingForPlatform", BindingFlags.NonPublic | BindingFlags.Static);
- int staticBatchingValue = 1;
- int dynamicBatchingValue = 1;
- object[] param = new object[] { BuildTarget.Android, staticBatchingValue, dynamicBatchingValue };
- method.Invoke(null, param);
- QualitySettings.SetQualityLevel(2);
- }
- static void PhoneSet()
- {
- PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel28;
- PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto;
- PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Android, ApiCompatibilityLevel.NET_4_6);
- PlayerSettings.SetMobileMTRendering(BuildTargetGroup.Android, true);
- PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false);
- PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new UnityEngine.Rendering.GraphicsDeviceType[1] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 });
- PlayerSettings.defaultInterfaceOrientation = UIOrientation.LandscapeLeft;
- EditorSettings.serializationMode = SerializationMode.ForceText;
- PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
- Android.targetArchitectures = AndroidArchitecture.ARM64;
- Type playerSettingsType = typeof(PlayerSettings);
- MethodInfo method = playerSettingsType.GetMethod("SetBatchingForPlatform", BindingFlags.NonPublic | BindingFlags.Static);
- int staticBatchingValue = 1;
- int dynamicBatchingValue = 1;
- object[] param = new object[] { BuildTarget.Android, staticBatchingValue, dynamicBatchingValue };
- method.Invoke(null, param);
- QualitySettings.SetQualityLevel(2);
- }
- static void RhinoxSet()
- {
- PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel28;
- PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto;
- PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Android, ApiCompatibilityLevel.NET_4_6);
- PlayerSettings.SetMobileMTRendering(BuildTargetGroup.Android, true);
- PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false);
- PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new UnityEngine.Rendering.GraphicsDeviceType[1] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 });
- PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait;
- EditorSettings.serializationMode = SerializationMode.ForceText;
- PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
- Android.targetArchitectures = AndroidArchitecture.ARM64;
- Type playerSettingsType = typeof(PlayerSettings);
- MethodInfo method = playerSettingsType.GetMethod("SetBatchingForPlatform", BindingFlags.NonPublic | BindingFlags.Static);
- int staticBatchingValue = 1;
- int dynamicBatchingValue = 1;
- object[] param = new object[] { BuildTarget.Android, staticBatchingValue, dynamicBatchingValue };
- method.Invoke(null, param);
- QualitySettings.SetQualityLevel(2);
- }
- static void NrealSet()
- {
- PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel28;
- PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto;
- PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Android, ApiCompatibilityLevel.NET_4_6);
- PlayerSettings.SetMobileMTRendering(BuildTargetGroup.Android, true);
- PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false);
- PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new UnityEngine.Rendering.GraphicsDeviceType[1] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 });
- PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
- Android.targetArchitectures = AndroidArchitecture.ARM64;
- PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait;
- EditorSettings.serializationMode = SerializationMode.ForceText;
- Type playerSettingsType = typeof(PlayerSettings);
- MethodInfo method = playerSettingsType.GetMethod("SetBatchingForPlatform", BindingFlags.NonPublic | BindingFlags.Static);
- int staticBatchingValue = 1;
- int dynamicBatchingValue = 1;
- object[] param = new object[] { BuildTarget.Android, staticBatchingValue, dynamicBatchingValue };
- method.Invoke(null, param);
- QualitySettings.SetQualityLevel(2);
- }
- static void A01Set()
- {
- PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel26;
- PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto;
- PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Android, ApiCompatibilityLevel.NET_4_6);
- PlayerSettings.SetMobileMTRendering(BuildTargetGroup.Android, false);
- PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false);
- PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new UnityEngine.Rendering.GraphicsDeviceType[1] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 });
- PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
- Android.targetArchitectures = AndroidArchitecture.ARMv7;
- PlayerSettings.defaultInterfaceOrientation = UIOrientation.LandscapeLeft;
- EditorSettings.serializationMode = SerializationMode.ForceText;
- Type playerSettingsType = typeof(PlayerSettings);
- MethodInfo method = playerSettingsType.GetMethod("SetBatchingForPlatform", BindingFlags.NonPublic | BindingFlags.Static);
- int staticBatchingValue = 1;
- int dynamicBatchingValue = 1;
- object[] param = new object[] { BuildTarget.Android, staticBatchingValue, dynamicBatchingValue };
- method.Invoke(null, param);
- QualitySettings.SetQualityLevel(2);
- }
- IEnumerator MyCoroutine()
- {
- Debug.Log("Coroutine started");
- yield return new WaitForSeconds(2);
- Debug.Log("Coroutine finished");
- }
-
- static void PlayerSet(string type)
- {
- GHZSDKSettings.isNewSDK=false;
- GHZSDKSettings.loadSDKType = type;
- try
- {
- FileUtil.DeleteFileOrDirectory("Assets/GHZSDK");
- }
- catch
- {
- }
- EditorApplication.delayCall += () =>
- {
- System.Threading.Thread.Sleep(1000);
- Debug.Log("正在卸载插件:jh.xr.engine");
- RemoveRequest rr = Client.Remove("jh.xr.engine");
- while (!rr.IsCompleted)
- {
- // 等待PackageManager请求完成
- }
- Directory.CreateDirectory("Assets/GHZSDK");
- Debug.Log("卸载 完成 :jh.xr.engine");
- rr = Client.Remove("com.ximmerse.xr");
- Debug.Log("正在卸载插件:com.ximmerse.xr");
- while (!rr.IsCompleted)
- {
- // 等待PackageManager请求完成
- }
- Debug.Log("卸载 完成 :com.ximmerse.xr");
- string[] strlist = new string[4];
- strlist[0] = "com.unity.xr.arcore@4.2.8";
- strlist[1] = "https://gogs.ghz-tech.com:8843/GHzGlass/GHZClassSDKXR.git#XRSDK_" + type;
- strlist[2] = "com.unity.xr.arfoundation@4.2.8";
- strlist[3] = "com.unity.xr.openxr@1.5.3";
- AddAndRemoveRequest rest = Client.AddAndRemove(strlist);
- Debug.Log("正在加载插件包:" + strlist.ToString());
- while (!rest.IsCompleted)
- {
- // 等待PackageManager请求完成
- }
- // ListRequest request = Client.List(true);
- // LoadSamplesSettings.PlayerShadowSDKSamplesSet(request);
- };
- }
- }
|