FTME01_ParticleControllerEditor.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4. [CustomEditor(typeof(FTME01_ParticleController))]
  5. public class FTME01_ParticleControllerEditor : Editor {
  6. private SerializedProperty scaleProperty;
  7. private SerializedProperty scaleLifeProperty;
  8. void OnEnable(){
  9. scaleProperty = serializedObject.FindProperty("scale");
  10. scaleLifeProperty = serializedObject.FindProperty("scaleLife");
  11. }
  12. public override void OnInspectorGUI()
  13. {
  14. //DrawDefaultInspector();
  15. FTME01_ParticleController myScript = (FTME01_ParticleController)target;
  16. serializedObject.Update();
  17. var scaleValue = EditorGUILayout.Slider( "Scaling Particle", scaleProperty.floatValue, 0.1f, 10.0f );
  18. if (scaleValue != scaleProperty.floatValue)
  19. {
  20. scaleProperty.floatValue = scaleValue;
  21. }
  22. var scaleLifeValue = EditorGUILayout.Slider( "Scaling Lifetime", scaleLifeProperty.floatValue, 0.1f, 10.0f );
  23. if (scaleLifeValue != scaleLifeProperty.floatValue)
  24. {
  25. scaleLifeProperty.floatValue = scaleLifeValue;
  26. }
  27. EditorGUILayout.LabelField ("Color Editor");
  28. EditorGUILayout.LabelField ("------------------------------------------------------------------------------------------------------------------------------");
  29. EditorGUILayout.PropertyField(serializedObject.FindProperty("particleSystems"),true);
  30. EditorGUILayout.PropertyField(serializedObject.FindProperty("particleColor"),true);
  31. EditorGUILayout.BeginHorizontal();
  32. if(GUILayout.Button("Get Particle Color"))
  33. {
  34. myScript.GetColor();
  35. }
  36. if(GUILayout.Button("Clear"))
  37. {
  38. myScript.ClearColor();
  39. }
  40. EditorGUILayout.EndHorizontal();
  41. serializedObject.ApplyModifiedProperties();
  42. }
  43. }