/// <summary>
        /// Shows the curve editor window that allows the user to edit a curve range (two curves).
        /// </summary>
        /// <param name="curveA">First curve of the range to display/edit.</param>
        /// <param name="curveB">Second curve of the range to display/edit.</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 curveA, AnimationCurve curveB,
                                             Action <bool, AnimationCurve, AnimationCurve> closedCallback = null)
        {
            CurveEditorWindow picker = new CurveEditorWindow(curveA, curveB, closedCallback);

            return(picker);
        }
Example #2
0
        partial void Callback_OnClicked(VectorComponent component)
        {
            FloatDistribution distribution = Value;

            if (DistributionType == PropertyDistributionType.Curve)
            {
                CurveEditorWindow.Show(distribution.GetMinCurve(), (success, curve) =>
                {
                    if (!success)
                    {
                        return;
                    }

                    Value = new FloatDistribution(curve);
                    OnCurveChanged?.Invoke();
                });
            }
            else if (DistributionType == PropertyDistributionType.RandomCurveRange)
            {
                CurveEditorWindow.Show(distribution.GetMinCurve(), distribution.GetMaxCurve(),
                                       (success, minCurve, maxCurve) =>
                {
                    if (!success)
                    {
                        return;
                    }

                    Value = new FloatDistribution(minCurve, maxCurve);
                    OnCurveChanged?.Invoke();
                });
            }
        }
        partial void OnClicked(int component)
        {
            Vector2Distribution distribution = Value;

            if (DistributionType == PropertyDistributionType.Curve)
            {
                AnimationCurve[] curves = AnimationUtility.SplitCurve2D(distribution.GetMinCurve());
                if (component < curves.Length)
                {
                    CurveEditorWindow.Show(curves[component], (success, curve) =>
                    {
                        if (!success)
                        {
                            return;
                        }

                        curves[component] = curve;

                        Vector2Curve compoundCurve = AnimationUtility.CombineCurve2D(curves);
                        Value = new Vector2Distribution(compoundCurve);
                        OnChanged?.Invoke();
                        OnConfirmed?.Invoke();
                    });
                }
            }
            else if (DistributionType == PropertyDistributionType.RandomCurveRange)
            {
                AnimationCurve[] minCurves = AnimationUtility.SplitCurve2D(distribution.GetMinCurve());
                AnimationCurve[] maxCurves = AnimationUtility.SplitCurve2D(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;

                        Vector2Curve minCompoundCurves = AnimationUtility.CombineCurve2D(minCurves);
                        Vector2Curve maxCompoundCurves = AnimationUtility.CombineCurve2D(maxCurves);

                        Value = new Vector2Distribution(minCompoundCurves, maxCompoundCurves);
                        OnChanged?.Invoke();
                        OnConfirmed?.Invoke();
                    });
                }
            }
        }
        /// <summary>
        /// Callback triggered when the user clicks on the GUI element.
        /// </summary>
        partial void Callback_OnClicked()
        {
            CurveEditorWindow.Show(Curve, (success, curve) =>
            {
                if (!success)
                {
                    return;
                }

                SetCurve(curve);
                OnChanged?.Invoke(curve);
            });
        }