API_Module_SDKSystem.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 
  2. using SC.XR.Unity.Module_SDKVersion;
  3. using SC.XR.Unity.Module_Device;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using UnityEngine;
  8. using SC.XR.Unity.Module_SDKSystem;
  9. public class API_Module_SDKSystem {
  10. public static Module_SDKSystem Instance {
  11. get {
  12. return Module_SDKSystem.Instance;
  13. }
  14. }
  15. public static bool SetSDKSystemHeight(float height,float Min=0,float Max=2.5f) {
  16. if (Instance) {
  17. Vector3 tran = Instance.transform.localPosition;
  18. tran.y = Mathf.Clamp(height, -10000, 10000);//Mathf.Clamp(height, Min, Max);
  19. Instance.transform.localPosition = tran;
  20. if (SetSDKSystemHeightEvent!=null) {
  21. SetSDKSystemHeightEvent(tran.y);
  22. }
  23. return true;
  24. }
  25. return false;
  26. }
  27. public static float GetSDKSystemHeight()
  28. {
  29. if (Instance)
  30. {
  31. Vector3 tran = Instance.transform.localPosition;
  32. return tran.y;
  33. }
  34. return 0f;
  35. }
  36. static Action<float> SetSDKSystemHeightEvent;
  37. public static void BindSetSDKSystemHeightEvent(Action<float> Fun) {
  38. if (Fun != null) {
  39. SetSDKSystemHeightEvent += Fun;
  40. }
  41. }
  42. public static void UnBindSetSDKSystemHeightEvent(Action<float> Fun) {
  43. if (Fun != null) {
  44. SetSDKSystemHeightEvent -= Fun;
  45. }
  46. }
  47. }