BaseTemPlate.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. private void Update()
  74. {
  75. if(state&&!UserInfo.Instance.is20)
  76. {
  77. HideCollider();
  78. }
  79. // HideCollider();
  80. }
  81. protected virtual void OnEnable()
  82. {
  83. }
  84. /// <summary>
  85. /// 用户端执行代码
  86. /// 隐藏碰撞器及移动缩放功能,在用户端只观看不进行任何操作
  87. /// </summary>
  88. public virtual void HideCollider()
  89. {
  90. state = true;
  91. if (GetComponent<BoxCollider>() != null)
  92. GetComponent<BoxCollider>().enabled = GameManager.Instance.IsStartEditor;
  93. if (GetComponent<BoundingBox>() != null)
  94. GetComponent<BoundingBox>().enabled = GameManager.Instance.IsStartEditor;
  95. if (GetComponent<ManipulationHandler>() != null)
  96. GetComponent<ManipulationHandler>().enabled = GameManager.Instance.IsStartEditor;
  97. if (transform.Find("BoundingBox") != null)
  98. transform.Find("BoundingBox").gameObject.SetActive(GameManager.Instance.IsStartEditor);
  99. }
  100. /// <summary>
  101. /// 设置素材属性
  102. /// </summary>
  103. /// <param name="value">当前素材数据</param>
  104. public virtual void SetData(MaterialObjValue value, int updateTime)
  105. {
  106. m_SuCaiData = value;
  107. // Debug.Log("@@@@@ " );
  108. // Data = new DownloadData(value);
  109. // Debug.Log("@@@@@ " + Data.localSavePath);
  110. // Data.updateTime = updateTime;
  111. IsSetData = false;
  112. }
  113. protected virtual void OnAwake()
  114. {
  115. // Data = null;
  116. }
  117. protected virtual void OnInit()
  118. {
  119. }
  120. }