SmoothModifierEditor.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using UnityEngine;
  2. using UnityEditor;
  3. namespace Pathfinding {
  4. [CustomEditor(typeof(SimpleSmoothModifier))]
  5. [CanEditMultipleObjects]
  6. public class SmoothModifierEditor : EditorBase {
  7. protected override void Inspector () {
  8. var smoothType = FindProperty("smoothType");
  9. PropertyField("smoothType");
  10. if (!smoothType.hasMultipleDifferentValues) {
  11. switch ((SimpleSmoothModifier.SmoothType)smoothType.enumValueIndex) {
  12. case SimpleSmoothModifier.SmoothType.Simple:
  13. if (PropertyField("uniformLength")) {
  14. FloatField("maxSegmentLength", min: 0.005f);
  15. } else {
  16. IntSlider("subdivisions", 0, 6);
  17. }
  18. PropertyField("iterations");
  19. ClampInt("iterations", 0);
  20. PropertyField("strength");
  21. break;
  22. case SimpleSmoothModifier.SmoothType.OffsetSimple:
  23. PropertyField("iterations");
  24. ClampInt("iterations", 0);
  25. FloatField("offset", min: 0f);
  26. break;
  27. case SimpleSmoothModifier.SmoothType.Bezier:
  28. IntSlider("subdivisions", 0, 6);
  29. PropertyField("bezierTangentLength");
  30. break;
  31. case SimpleSmoothModifier.SmoothType.CurvedNonuniform:
  32. FloatField("maxSegmentLength", min: 0.005f);
  33. PropertyField("factor");
  34. break;
  35. }
  36. }
  37. }
  38. }
  39. }