GUIFloatDistributionField.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using bs;
  3. namespace bs.Editor
  4. {
  5. partial class GUIFloatDistributionField
  6. {
  7. /// <summary>
  8. /// Triggered when one of the curves in the distribution changes.
  9. /// </summary>
  10. public event Action OnCurveChanged;
  11. partial void Callback_OnClicked(VectorComponent component)
  12. {
  13. FloatDistribution distribution = Value;
  14. if (DistributionType == PropertyDistributionType.Curve)
  15. {
  16. CurveEditorWindow.Show(distribution.GetMinCurve(), (success, curve) =>
  17. {
  18. if (!success)
  19. return;
  20. Value = new FloatDistribution(curve);
  21. OnCurveChanged?.Invoke();
  22. });
  23. }
  24. else if (DistributionType == PropertyDistributionType.RandomCurveRange)
  25. {
  26. CurveEditorWindow.Show(distribution.GetMinCurve(), distribution.GetMaxCurve(),
  27. (success, minCurve, maxCurve) =>
  28. {
  29. if (!success)
  30. return;
  31. Value = new FloatDistribution(minCurve, maxCurve);
  32. OnCurveChanged?.Invoke();
  33. });
  34. }
  35. }
  36. }
  37. }