FPlayEffectEventInspector.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using UnityEngine;
  2. using UnityEditor;
  3. using Flux;
  4. namespace FluxEditor
  5. {
  6. [CustomEditor(typeof(FPlayEffectEvent))]
  7. public class FPlayEffectEventInspector : FEventInspector
  8. {
  9. private FPlayEffectEvent _effectEvent = null;
  10. private SerializedProperty _effectId = null;
  11. private SerializedProperty _effectPrefab = null;
  12. private SerializedProperty _effectLink = null;
  13. private int effectLinkIdx = -1;
  14. protected override void OnEnable()
  15. {
  16. base.OnEnable();
  17. _effectEvent = (FPlayEffectEvent)target;
  18. _effectId = serializedObject.FindProperty("_effectId");
  19. _effectPrefab = serializedObject.FindProperty("_effectPrefab");
  20. _effectLink = serializedObject.FindProperty("_effectLink");
  21. for(int idx =0; idx < linkPoints.Length;idx++)
  22. {
  23. if(linkPoints[idx] == _effectLink.stringValue)
  24. {
  25. effectLinkIdx = idx;
  26. break;
  27. }
  28. }
  29. }
  30. public override void OnInspectorGUI()
  31. {
  32. base.OnInspectorGUI();
  33. serializedObject.Update();
  34. EditorGUILayout.BeginHorizontal();
  35. GUILayout.Label("特效ID:", EditorStyles.label, GUILayout.Width(140));
  36. _effectId.intValue = EditorGUILayout.IntField(_effectId.intValue, GUILayout.Width(300));
  37. EditorGUILayout.EndHorizontal();
  38. EditorGUILayout.BeginHorizontal();
  39. GUILayout.Label("特效预设:", EditorStyles.label, GUILayout.Width(140));
  40. _effectPrefab.objectReferenceValue = EditorGUILayout.ObjectField(_effectPrefab.objectReferenceValue, typeof(GameObject), false, GUILayout.Width(300));
  41. EditorGUILayout.EndHorizontal();
  42. EditorGUILayout.BeginHorizontal();
  43. GUILayout.Label("挂载点:", EditorStyles.label, GUILayout.Width(140));
  44. effectLinkIdx = EditorGUILayout.Popup(effectLinkIdx, linkPoints, GUILayout.Width(300));
  45. if (effectLinkIdx >= 0)
  46. _effectLink.stringValue = linkPoints[effectLinkIdx];
  47. EditorGUILayout.EndHorizontal();
  48. serializedObject.ApplyModifiedProperties();
  49. }
  50. }
  51. }