GUIFloatDistributionField.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using BansheeEngine;
  3. namespace BansheeEditor
  4. {
  5. partial class GUIFloatDistributionField
  6. {
  7. /// <summary>
  8. /// Triggered when the distribution in the field changes.
  9. /// </summary>
  10. public event Action OnChanged;
  11. /// <summary>
  12. /// Triggered whenever user confirms input in one of the floating point fields.
  13. /// </summary>
  14. public event Action OnConfirmed;
  15. partial void OnClicked(int component)
  16. {
  17. FloatDistribution distribution = Value;
  18. if (distribution.DistributionType == PropertyDistributionType.Curve)
  19. {
  20. CurveEditorWindow.Show(distribution.GetMinCurve(), (success, curve) =>
  21. {
  22. if (!success)
  23. return;
  24. Value = new FloatDistribution(curve);
  25. OnChanged?.Invoke();
  26. });
  27. }
  28. else if (distribution.DistributionType == PropertyDistributionType.RandomCurveRange)
  29. {
  30. CurveEditorWindow.Show(distribution.GetMinCurve(), distribution.GetMaxCurve(),
  31. (success, minCurve, maxCurve) =>
  32. {
  33. if (!success)
  34. return;
  35. Value = new FloatDistribution(minCurve, maxCurve);
  36. OnChanged?.Invoke();
  37. });
  38. }
  39. }
  40. partial void OnConstantModified()
  41. {
  42. OnChanged?.Invoke();
  43. }
  44. partial void OnConstantConfirmed()
  45. {
  46. OnConfirmed?.Invoke();
  47. }
  48. }
  49. }