// Called by OnEnable to make sure the CurveEditor is not null,
        // and by Show so we get a fresh CurveEditor when the user clicks a new curve.
        void Init(CurveEditorSettings settings)
        {
            m_CurveEditor = new CurveEditor(GetCurveEditorRect(), GetCurveWrapperArray(), true);
            m_CurveEditor.curvesUpdated   = UpdateCurve;
            m_CurveEditor.scaleWithWindow = true;
            m_CurveEditor.margin          = 40;
            if (settings != null)
            {
                m_CurveEditor.settings = settings;
            }
            m_CurveEditor.settings.hTickLabelOffset   = 10;
            m_CurveEditor.settings.rectangleToolFlags = CurveEditorSettings.RectangleToolFlags.MiniRectangleTool;
            m_CurveEditor.settings.undoRedoSelection  = true;
            m_CurveEditor.settings.showWrapperPopups  = true;
            m_CurveEditor.settings.xAxisLabel         = xAxisLabel;
            UpdateRegionDomain();

            // For each of horizontal and vertical axis, if we have a finite range for that axis, use that range,
            // otherwise use framing logic to determine shown range for that axis.
            bool frameH = true;
            bool frameV = true;

            if (!float.IsNegativeInfinity(m_CurveEditor.settings.hRangeMin) && !float.IsInfinity(m_CurveEditor.settings.hRangeMax))
            {
                m_CurveEditor.SetShownHRangeInsideMargins(m_CurveEditor.settings.hRangeMin, m_CurveEditor.settings.hRangeMax);
                frameH = false;
            }
            if (!float.IsNegativeInfinity(m_CurveEditor.settings.vRangeMin) && !float.IsInfinity(m_CurveEditor.settings.vRangeMax))
            {
                m_CurveEditor.SetShownVRangeInsideMargins(m_CurveEditor.settings.vRangeMin, m_CurveEditor.settings.vRangeMax);
                frameV = false;
            }

            m_CurveEditor.FrameSelected(frameH, frameV);
        }
Beispiel #2
0
        public void Show(GUIView viewToUpdate, CurveEditorSettings settings)
        {
            delegateView     = viewToUpdate;
            m_OnCurveChanged = null;

            Init(settings);
            ShowAuxWindow();
        }
Beispiel #3
0
        public void Show(Action <AnimationCurve> onCurveChanged, CurveEditorSettings settings)
        {
            m_OnCurveChanged = onCurveChanged;
            delegateView     = null;

            Init(settings);
            ShowAuxWindow();
        }
        public void Show(GUIView viewToUpdate, CurveEditorSettings settings)
        {
            delegateView = viewToUpdate;
            Init(settings);
            ShowAuxWindow();
            titleContent = EditorGUIUtility.TrTextContent("Curve Editor");

            // deal with window size
            minSize = new Vector2(k_WindowMinSize, k_WindowMinSize + k_PresetsHeight);
            maxSize = new Vector2(k_WindowMaxSize, k_WindowMaxSize);
        }
Beispiel #5
0
        // Called by OnEnable to make sure the CurveEditor is not null,
        // and by Show so we get a fresh CurveEditor when the user clicks a new curve.
        void Init(CurveEditorSettings settings)
        {
            m_CurveEditor = new CurveEditor(GetCurveEditorRect(), GetCurveWrapperArray(), true);
            m_CurveEditor.curvesUpdated   = UpdateCurve;
            m_CurveEditor.scaleWithWindow = true;
            m_CurveEditor.margin          = 40;
            if (settings != null)
            {
                m_CurveEditor.settings = settings;
            }
            m_CurveEditor.settings.hTickLabelOffset   = 10;
            m_CurveEditor.settings.rectangleToolFlags = CurveEditorSettings.RectangleToolFlags.MiniRectangleTool;

            // As there is no guarantee animation curve changes are recorded in undo redo, we can't really
            // handle curve selection in undo redo either.
            m_CurveEditor.settings.undoRedoSelection = false;
            m_CurveEditor.settings.showWrapperPopups = true;

            // For each of horizontal and vertical axis, if we have a finite range for that axis, use that range,
            // otherwise use framing logic to determine shown range for that axis.
            bool frameH = true;
            bool frameV = true;

            if (m_CurveEditor.settings.hRangeMin != Mathf.NegativeInfinity && m_CurveEditor.settings.hRangeMax != Mathf.Infinity)
            {
                m_CurveEditor.SetShownHRangeInsideMargins(m_CurveEditor.settings.hRangeMin, m_CurveEditor.settings.hRangeMax);
                frameH = false;
            }
            if (m_CurveEditor.settings.vRangeMin != Mathf.NegativeInfinity && m_CurveEditor.settings.vRangeMax != Mathf.Infinity)
            {
                m_CurveEditor.SetShownVRangeInsideMargins(m_CurveEditor.settings.vRangeMin, m_CurveEditor.settings.vRangeMax);
                frameV = false;
            }

            m_CurveEditor.FrameSelected(frameH, frameV);

            titleContent = EditorGUIUtility.TrTextContent("Curve");

            // deal with window size
            minSize = new Vector2(240, 240 + kPresetsHeight);
            maxSize = new Vector2(10000, 10000);
        }