SafetyAreaMono.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using SC.XR.Unity;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.EventSystems;
  6. public class SafetyAreaMono : MonoBehaviour
  7. {
  8. public Material safetyPlaneMat;
  9. public Material safetyPlaneConfirmedMat;
  10. public Material safetyPlaneHoverMat;
  11. public Material areaConfirmMat;
  12. public Material areaNormalMat;
  13. public GroundHeightUI groundHeightUI;
  14. public PlayAreaWaitingDrawUI playAreaWaitingDrawUI;
  15. public PlayAreaNotEnoughUI playAreaNotEnoughUI;
  16. public PlayAreaOKUI playAreaOKUI;
  17. public StationaryAreaUI stationaryAreaUI;
  18. public ConfirmPlayAreaUI confirmPlayAreaUI;
  19. public SafetyGreyCameraUI safetyGreyCameraUI;
  20. [HideInInspector]
  21. public SafetyPlaneMono safetyPlaneMono;
  22. private GameObject safetyPlaneObject;
  23. //[HideInInspector]
  24. //public StationaryAreaMono stationaryAreaMono;
  25. //private GameObject stationaryAreaObject;
  26. //[HideInInspector]
  27. //public PlayAreaMono playAreaMono;
  28. //private GameObject playAreaObject;
  29. private GroundHeightStep groundHeightStep;
  30. private void Awake()
  31. {
  32. DontDestroyOnLoad(this.gameObject);
  33. }
  34. public void Init(object data)
  35. {
  36. if (groundHeightStep == null)
  37. {
  38. groundHeightStep = SafetyAreaManager.Instance.GetStep<GroundHeightStep>(SafetyAreaStepEnum.GroundHeight);
  39. }
  40. SafetyAreaManager.Instance.ChangeStep(SafetyAreaStepEnum.GroundHeight, data);
  41. }
  42. public void Release()
  43. {
  44. }
  45. //创建平面
  46. public void CreateSafetyPlane()
  47. {
  48. Debug.LogError("CreateSafetyPlane");
  49. if (safetyPlaneMono == null)
  50. {
  51. safetyPlaneObject = new GameObject("SafetyPlane");
  52. safetyPlaneMono = safetyPlaneObject.AddComponent<SafetyPlaneMono>();
  53. safetyPlaneMono.Init();
  54. safetyPlaneMono.DisableRenderer();
  55. }
  56. }
  57. public void EnablePlaneMeshRenderer()
  58. {
  59. if (safetyPlaneMono != null)
  60. {
  61. safetyPlaneMono.EnableRenderer();
  62. }
  63. }
  64. //销毁平面
  65. public void DestroySafetyPlane()
  66. {
  67. if (safetyPlaneObject != null)
  68. {
  69. GameObject.Destroy(safetyPlaneObject);
  70. }
  71. safetyPlaneObject = null;
  72. safetyPlaneMono = null;
  73. }
  74. }