BaseTemPlate.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using SC.XR.Unity.Module_InputSystem;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class BaseTemPlate : MonoBehaviour
  6. {
  7. private Transform m_Transform;
  8. private GameObject m_Go;
  9. private MaterialType m_SuCaiType;
  10. private MaterialObjValue m_SuCaiData;
  11. private DownloadData m_Data;
  12. private bool m_IsSetData = true;
  13. private bool state = false;
  14. public Transform CacheTransform
  15. {
  16. get
  17. {
  18. if (m_Transform == null)
  19. {
  20. m_Transform = transform;
  21. }
  22. return m_Transform;
  23. }
  24. }
  25. public GameObject CacheGameObject
  26. {
  27. get
  28. {
  29. if (this.m_Go == null)
  30. {
  31. this.m_Go = base.gameObject;
  32. }
  33. return this.m_Go;
  34. }
  35. }
  36. public MaterialType SuCaiType
  37. {
  38. get { return m_SuCaiType; }
  39. set { m_SuCaiType = value; }
  40. }
  41. public MaterialObjValue SuCaiData
  42. {
  43. get { return m_SuCaiData; }
  44. set { m_SuCaiData = value; }
  45. }
  46. public DownloadData Data
  47. {
  48. get { return m_Data; }
  49. set { m_Data = value; }
  50. }
  51. /// <summary>
  52. /// 是否为设置数据
  53. /// </summary>
  54. public bool IsSetData
  55. {
  56. get { return m_IsSetData; }
  57. set { m_IsSetData = value; }
  58. }
  59. private void Awake()
  60. {
  61. OnAwake();
  62. }
  63. public void Init()
  64. {
  65. OnInit();
  66. }
  67. private void Update()
  68. {
  69. if(state)
  70. {
  71. HideCollider();
  72. }
  73. // HideCollider();
  74. }
  75. protected virtual void OnEnable()
  76. {
  77. }
  78. /// <summary>
  79. /// 用户端执行代码
  80. /// 隐藏碰撞器及移动缩放功能,在用户端只观看不进行任何操作
  81. /// </summary>
  82. public virtual void HideCollider()
  83. {
  84. state = true;
  85. if (GetComponent<BoxCollider>() != null)
  86. GetComponent<BoxCollider>().enabled = GameManager.Instance.IsStartEditor;
  87. if (GetComponent<BoundingBox>() != null)
  88. GetComponent<BoundingBox>().enabled = GameManager.Instance.IsStartEditor;
  89. if (GetComponent<ManipulationHandler>() != null)
  90. GetComponent<ManipulationHandler>().enabled = GameManager.Instance.IsStartEditor;
  91. if (transform.Find("BoundingBox") != null)
  92. transform.Find("BoundingBox").gameObject.SetActive(GameManager.Instance.IsStartEditor);
  93. }
  94. /// <summary>
  95. /// 设置素材属性
  96. /// </summary>
  97. /// <param name="value">当前素材数据</param>
  98. public virtual void SetData(MaterialObjValue value, int updateTime)
  99. {
  100. m_SuCaiData = value;
  101. // Debug.Log("@@@@@ " );
  102. Data = new DownloadData(value);
  103. // Debug.Log("@@@@@ " + Data.localSavePath);
  104. Data.updateTime = updateTime;
  105. IsSetData = false;
  106. }
  107. protected virtual void OnAwake()
  108. {
  109. Data = null;
  110. }
  111. protected virtual void OnInit()
  112. {
  113. }
  114. }