BaseTemPlate.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 DownLoadMaterial m_Data;
  13. private bool m_IsSetData = true;
  14. private bool state = false;
  15. public Transform CacheTransform
  16. {
  17. get
  18. {
  19. if (m_Transform == null)
  20. {
  21. m_Transform = transform;
  22. }
  23. return m_Transform;
  24. }
  25. }
  26. public GameObject CacheGameObject
  27. {
  28. get
  29. {
  30. if (this.m_Go == null)
  31. {
  32. this.m_Go = base.gameObject;
  33. }
  34. return this.m_Go;
  35. }
  36. }
  37. public MaterialType SuCaiType
  38. {
  39. get { return m_SuCaiType; }
  40. set { m_SuCaiType = value; }
  41. }
  42. public MaterialObjValue SuCaiData
  43. {
  44. get { return m_SuCaiData; }
  45. set { m_SuCaiData = value; }
  46. }
  47. //public DownloadData Data
  48. //{
  49. // get { return m_Data; }
  50. // set { m_Data = value; }
  51. //}
  52. public DownLoadMaterial Data
  53. {
  54. get { return m_Data; }
  55. set { m_Data = value; }
  56. }
  57. /// <summary>
  58. /// 是否为设置数据
  59. /// </summary>
  60. public bool IsSetData
  61. {
  62. get { return m_IsSetData; }
  63. set { m_IsSetData = value; }
  64. }
  65. private void Awake()
  66. {
  67. OnAwake();
  68. }
  69. public void Init()
  70. {
  71. OnInit();
  72. }
  73. public virtual void Update()
  74. {
  75. if(state&&!UserInfo.Instance.is20)
  76. {
  77. HideCollider();
  78. }
  79. if(UserInfo.Instance.is20)
  80. {
  81. if (GetComponent<BoxCollider>() != null)
  82. GetComponent<BoxCollider>().enabled = GameManager.m_IsStart20Editor;
  83. if (GetComponent<BoundingBox>() != null)
  84. GetComponent<BoundingBox>().enabled = GameManager.m_IsStart20Editor;
  85. if (GetComponent<ManipulationHandler>() != null)
  86. GetComponent<ManipulationHandler>().enabled = GameManager.m_IsStart20Editor;
  87. if (transform.Find("BoundingBox") != null)
  88. transform.Find("BoundingBox").gameObject.SetActive(GameManager.m_IsStart20Editor);
  89. // HideCollider();
  90. }
  91. else
  92. {
  93. if (GetComponent<BoxCollider>() != null)
  94. GetComponent<BoxCollider>().enabled = GameManager.Instance.IsStartEditor;
  95. if (GetComponent<BoundingBox>() != null)
  96. GetComponent<BoundingBox>().enabled = GameManager.Instance.IsStartEditor;
  97. if (GetComponent<ManipulationHandler>() != null)
  98. GetComponent<ManipulationHandler>().enabled = GameManager.Instance.IsStartEditor;
  99. if (transform.Find("BoundingBox") != null)
  100. transform.Find("BoundingBox").gameObject.SetActive(GameManager.Instance.IsStartEditor);
  101. // HideCollider();
  102. }
  103. }
  104. protected virtual void OnEnable()
  105. {
  106. }
  107. /// <summary>
  108. /// 用户端执行代码
  109. /// 隐藏碰撞器及移动缩放功能,在用户端只观看不进行任何操作
  110. /// </summary>
  111. public virtual void HideCollider()
  112. {
  113. state = true;
  114. }
  115. /// <summary>
  116. /// 设置素材属性
  117. /// </summary>
  118. /// <param name="value">当前素材数据</param>
  119. public virtual void SetData(MaterialObjValue value, long updateTime)
  120. {
  121. m_SuCaiData = value;
  122. // Debug.Log("@@@@@ " );
  123. // Data = new DownloadData(value);
  124. // Debug.Log("@@@@@ " + Data.localSavePath);
  125. // Data.updateTime = updateTime;
  126. IsSetData = false;
  127. }
  128. protected virtual void OnAwake()
  129. {
  130. // Data = null;
  131. }
  132. protected virtual void OnInit()
  133. {
  134. }
  135. }