partial void OnClicked(int component) { FloatDistribution distribution = Value; if (DistributionType == PropertyDistributionType.Curve) { CurveEditorWindow.Show(distribution.GetMinCurve(), (success, curve) => { if (!success) { return; } Value = new FloatDistribution(curve); OnChanged?.Invoke(); }); } else if (DistributionType == PropertyDistributionType.RandomCurveRange) { CurveEditorWindow.Show(distribution.GetMinCurve(), distribution.GetMaxCurve(), (success, minCurve, maxCurve) => { if (!success) { return; } Value = new FloatDistribution(minCurve, maxCurve); OnChanged?.Invoke(); }); } }
/// <summary> /// Callback triggered when the user clicks on the curve display in the GUI element. /// </summary> partial void OnClicked() { FloatDistribution distribution = Value; if (distribution.DistributionType == PropertyDistributionType.Curve) { CurveEditorWindow.Show(distribution.GetMinCurve(), (success, curve) => { if (success) { Value = new FloatDistribution(curve); } }); } else if (distribution.DistributionType == PropertyDistributionType.RandomCurveRange) { CurveEditorWindow.Show(distribution.GetMinCurve(), distribution.GetMaxCurve(), (success, minCurve, maxCurve) => { if (success) { Value = new FloatDistribution(minCurve, maxCurve); } }); } }
partial void OnClicked(int component) { Vector3Distribution distribution = Value; if (DistributionType == PropertyDistributionType.Curve) { AnimationCurve[] curves = AnimationUtility.SplitCurve3D(distribution.GetMinCurve()); if (component < curves.Length) { CurveEditorWindow.Show(curves[component], (success, curve) => { if (!success) { return; } curves[component] = curve; Vector3Curve compoundCurve = AnimationUtility.CombineCurve3D(curves); Value = new Vector3Distribution(compoundCurve); OnChanged?.Invoke(); OnConfirmed?.Invoke(); }); } } else if (DistributionType == PropertyDistributionType.RandomCurveRange) { AnimationCurve[] minCurves = AnimationUtility.SplitCurve3D(distribution.GetMinCurve()); AnimationCurve[] maxCurves = AnimationUtility.SplitCurve3D(distribution.GetMaxCurve()); if (component < minCurves.Length && component < maxCurves.Length) { CurveEditorWindow.Show(minCurves[component], maxCurves[component], (success, minCurve, maxCurve) => { if (!success) { return; } minCurves[component] = minCurve; maxCurves[component] = maxCurve; Vector3Curve minCompoundCurves = AnimationUtility.CombineCurve3D(minCurves); Vector3Curve maxCompoundCurves = AnimationUtility.CombineCurve3D(maxCurves); Value = new Vector3Distribution(minCompoundCurves, maxCompoundCurves); OnChanged?.Invoke(); OnConfirmed?.Invoke(); }); } } }
/// <summary> /// Callback triggered when the user clicks on the GUI element. /// </summary> partial void OnClicked() { CurveEditorWindow.Show(Curve, (success, curve) => { if (!success) { return; } SetCurve(curve); OnChanged?.Invoke(curve); }); }
/// <summary> /// Shows the curve editor window that allows the user to edit a single curve. /// </summary> /// <param name="curve">Curve to initialize the window with.</param> /// <param name="closedCallback">Optional callback to trigger when the user finishes editing the curve or /// cancels out of the dialog.</param> /// <returns>An instance of the curve editor window.</returns> public static CurveEditorWindow Show(AnimationCurve curve, Action <bool, AnimationCurve> closedCallback = null) { CurveEditorWindow picker = new CurveEditorWindow(curve, closedCallback); return(picker); }