NoticeEditor.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using UnityEngine;
  5. namespace SC.XR.Unity
  6. {
  7. [CustomEditor(typeof(Module_Notice), true)]
  8. public class NoticeEditor : Editor
  9. {
  10. private SerializedProperty mainText;
  11. private SerializedProperty minorText;
  12. private SerializedProperty isFollow;
  13. private SerializedProperty distance;
  14. private SerializedProperty durationTime;
  15. private SerializedProperty noticetype;
  16. private SerializedProperty anchortype;
  17. protected void OnEnable()
  18. {
  19. mainText = serializedObject.FindProperty("_mainText");
  20. minorText = serializedObject.FindProperty("_minorText");
  21. isFollow = serializedObject.FindProperty("_isFollow");
  22. distance = serializedObject.FindProperty("_distance");
  23. durationTime = serializedObject.FindProperty("_durationTime");
  24. noticetype = serializedObject.FindProperty("_type");
  25. anchortype = serializedObject.FindProperty("_anchorType");
  26. }
  27. sealed public override void OnInspectorGUI()
  28. {
  29. serializedObject.Update();
  30. EditorGUILayout.PropertyField(mainText);
  31. EditorGUILayout.PropertyField(minorText);
  32. EditorGUILayout.PropertyField(durationTime);
  33. EditorGUILayout.PropertyField(isFollow);
  34. FollowType layoutFollow = (FollowType)isFollow.enumValueIndex;
  35. if (layoutFollow== FollowType.True)
  36. {
  37. EditorGUILayout.PropertyField(distance);
  38. EditorGUILayout.PropertyField(anchortype);
  39. }
  40. EditorGUILayout.PropertyField(noticetype);
  41. serializedObject.ApplyModifiedProperties();
  42. // Place the button at the bottom
  43. Module_Notice notice = (Module_Notice)target;
  44. if (GUILayout.Button("Refresh Info"))
  45. {
  46. notice.RefreshInfo();
  47. }
  48. }
  49. }
  50. }