Beispiel #1
0
        /// <summary>
        /// 1. draw spline
        /// 2. draw points
        /// 3. draw handles
        /// </summary>
        public void OnSceneGUI()
        {
            CatmullRomCentripetalBehaviour behaviour = (CatmullRomCentripetalBehaviour)target;
            CatmullRomCentripetal          spline    = (CatmullRomCentripetal)behaviour.Spline;
            Transform tr = behaviour.transform;

            DrawSpline(spline, tr);

            if (!ms_isMultiEdit)
            {
                DrawPoints(spline, tr);

                DrawHandles(spline, tr);

                // prevent de-selection by clicking
                EUtil.SceneViewPreventDeselecByClick(m_curPtIdx >= 0);

                // shortcut
                Event e = Event.current;
                switch (e.type)
                {
                case EventType.KeyUp:
                {
                    if (e.keyCode == KeyCode.X)
                    {
                        if (m_curPtIdx >= 0)
                        {
                            _DelPoint(spline);
                        }
                    }
                    else if (e.keyCode == KeyCode.I)
                    {
                        if (m_curPtIdx < 0)
                        {
                            m_curPtIdx = spline.PointCount - 1;
                        }
                        _AddPoint(spline);
                    }
                    else if (e.keyCode == KeyCode.C)
                    {
                        if (m_curPtIdx >= 0)
                        {
                            EUtil.SceneViewLookAt(tr.TransformPoint(spline[m_curPtIdx]), ms_lookAtDist);
                        }
                    }
                }
                break;
                }
            }
        }