FMoveEventInspector.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using UnityEngine;
  2. using UnityEditor;
  3. using Flux;
  4. namespace FluxEditor
  5. {
  6. [CustomEditor(typeof(FMoveEvent))]
  7. public class FMoveEventInspector : FEventInspector
  8. {
  9. private FMoveEvent _moveEvent = null;
  10. private SerializedProperty _moveType = null;
  11. private SerializedProperty _initSpeed = null;
  12. private SerializedProperty _acceleration = null;
  13. private SerializedProperty _moveDistance = null;
  14. private SerializedProperty _moveOrientation = null;
  15. int[] moveTypes = new int[] { 0, 1, 2, 3, 4, 5, 6 };
  16. string[] moveTypeStrs = new string[] { "无", "击退", "冲刺到位置", "冲刺到目标", "跳起", "击飞", "掉落" };
  17. protected override void OnEnable()
  18. {
  19. base.OnEnable();
  20. _moveEvent = (FMoveEvent)target;
  21. _moveType = serializedObject.FindProperty("_moveType");
  22. _initSpeed = serializedObject.FindProperty("_initSpeed");
  23. _acceleration = serializedObject.FindProperty("_acceleration");
  24. _moveDistance = serializedObject.FindProperty("_moveDistance");
  25. _moveOrientation = serializedObject.FindProperty("_moveOrientation");
  26. }
  27. public override void OnInspectorGUI()
  28. {
  29. base.OnInspectorGUI();
  30. serializedObject.Update();
  31. EditorGUILayout.BeginHorizontal();
  32. GUILayout.Label("移动类型:", EditorStyles.label, GUILayout.Width(140));
  33. _moveType.intValue = EditorGUILayout.IntPopup(_moveType.intValue,moveTypeStrs,moveTypes);
  34. EditorGUILayout.EndHorizontal();
  35. EditorGUILayout.BeginHorizontal();
  36. GUILayout.Label("初始速度:", EditorStyles.label, GUILayout.Width(140));
  37. _initSpeed.floatValue = EditorGUILayout.FloatField(_initSpeed.floatValue);
  38. EditorGUILayout.EndHorizontal();
  39. EditorGUILayout.BeginHorizontal();
  40. GUILayout.Label("加速度:", EditorStyles.label, GUILayout.Width(140));
  41. _acceleration.floatValue = EditorGUILayout.FloatField(_acceleration.floatValue);
  42. EditorGUILayout.EndHorizontal();
  43. EditorGUILayout.BeginHorizontal();
  44. GUILayout.Label("移动距离:", EditorStyles.label, GUILayout.Width(140));
  45. _moveDistance.floatValue = EditorGUILayout.FloatField(_moveDistance.floatValue);
  46. EditorGUILayout.EndHorizontal();
  47. EditorGUILayout.BeginHorizontal();
  48. GUILayout.Label("移动方向:", EditorStyles.label, GUILayout.Width(140));
  49. _moveOrientation.intValue = EditorGUILayout.IntField(_moveOrientation.intValue);
  50. EditorGUILayout.EndHorizontal();
  51. serializedObject.ApplyModifiedProperties();
  52. }
  53. }
  54. }