EditorPanel.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class EditorPanel : MonoBehaviour
  6. {
  7. /// <summary>
  8. /// 景点
  9. /// </summary>
  10. private UISpoitsPanel m_SpoitsPanel;
  11. /// <summary>
  12. /// 素材面板
  13. /// </summary>
  14. private UIMaterialsPanel m_MaterialsPanel;
  15. /// <summary>
  16. /// 添加素材面板
  17. /// </summary>
  18. private UIAddMaterialPanel m_AddMaterialPanel;
  19. /// <summary>
  20. /// 素材编辑面板
  21. /// </summary>
  22. private UIEditorPanel m_EditorPanel;
  23. // private UIAnchorsPanel m_AnchorsPanel;
  24. /// <summary>
  25. /// 当前触发的景点名称
  26. /// </summary>
  27. private string m_SpoitName;
  28. private void Awake()
  29. {
  30. m_SpoitsPanel = transform.Find("UISpoits").gameObject.AddComponent<UISpoitsPanel>();
  31. m_MaterialsPanel = transform.Find("UIMaterials").gameObject.AddComponent<UIMaterialsPanel>();
  32. m_MaterialsPanel.EditorPanel = this;
  33. // m_AnchorsPanel = transform.Find("UIAnchor").gameObject.GetComponent<UIAnchorsPanel>();
  34. m_AddMaterialPanel = transform.Find("UIAddMaterial").gameObject.AddComponent<UIAddMaterialPanel>();
  35. m_AddMaterialPanel.EditorPanel = this;
  36. m_AddMaterialPanel.OnClickAddMatBtn += OnClickAddMatBtn;
  37. m_EditorPanel = transform.Find("UIEditor").gameObject.GetComponent<UIEditorPanel>();
  38. m_EditorPanel.OnClickRemoveBtn += onClickRemoveBtn;
  39. }
  40. private void OnClickAddMatBtn()
  41. {
  42. m_MaterialsPanel.SaveSpoits();
  43. }
  44. private void onClickRemoveBtn(GameObject obj)
  45. {
  46. m_MaterialsPanel.RemoveMat(obj);
  47. }
  48. public void Init()
  49. {
  50. m_AddMaterialPanel.Init();
  51. }
  52. public void SetSpoit(SpoitValue spoit)
  53. {
  54. if (spoit != null)
  55. {
  56. m_SpoitName = spoit.name;
  57. m_SpoitsPanel.SetSpoit(m_SpoitName, true);
  58. }
  59. else
  60. {
  61. m_SpoitName = null;
  62. m_SpoitsPanel.SetSpoit("", false);
  63. }
  64. m_MaterialsPanel.SetMaterial(spoit);
  65. }
  66. public void ClosePanel()
  67. {
  68. m_SpoitName = null;
  69. m_SpoitsPanel.SetSpoit("", false);
  70. m_MaterialsPanel.ClosePanel();
  71. }
  72. //public void SetSpoit(List<ObjectValue> spoitObjs)
  73. //{
  74. // if (spoitObjs != null)
  75. // {
  76. // m_SpoitName = spoitObjs[0].Object.name;
  77. // m_SpoitsPanel.SetSpoit(m_SpoitName, true);
  78. // }
  79. // else
  80. // {
  81. // m_SpoitName = null;
  82. // m_SpoitsPanel.SetSpoit(m_SpoitName, false);
  83. // }
  84. // m_MaterialsPanel.SetMaterial(spoitObjs);
  85. //}
  86. public void InitObjTransForm()
  87. {
  88. m_MaterialsPanel.InitObjTransForm();
  89. }
  90. public void SaveObjTransForm()
  91. {
  92. m_MaterialsPanel.SaveMatObj();
  93. }
  94. public void ChangeShowUI(bool isShowEditor)
  95. {
  96. m_EditorPanel.gameObject.SetActive(isShowEditor);
  97. m_AddMaterialPanel.gameObject.SetActive(!isShowEditor);
  98. }
  99. private void OnDestroy()
  100. {
  101. m_EditorPanel.OnClickRemoveBtn -= onClickRemoveBtn;
  102. }
  103. }