void DrawWaypointEditor(Rect rect, int index)
        {
            // Needed for accessing string names of fields
            CinemachineSmoothPathForCarDrift.Waypoint def = new CinemachineSmoothPathForCarDrift.Waypoint();
            SerializedProperty element = mWaypointList.serializedProperty.GetArrayElementAtIndex(index);

            float hSpace = 3;

            rect.width -= hSpace; rect.y += 1;
            Vector2 numberDimension = GUI.skin.label.CalcSize(new GUIContent("999"));
            Rect    r = new Rect(rect.position, numberDimension);

            if (GUI.Button(r, new GUIContent(index.ToString(), "Go to the waypoint in the scene view")))
            {
                if (SceneView.lastActiveSceneView != null)
                {
                    mWaypointList.index = index;
                    SceneView.lastActiveSceneView.pivot = Target.EvaluatePosition(index);
                    SceneView.lastActiveSceneView.size  = 4;
                    SceneView.lastActiveSceneView.Repaint();
                }
            }

            float      floatFieldWidth = EditorGUIUtility.singleLineHeight * 2f;
            GUIContent rollLabel       = new GUIContent("翻滚");
            GUIContent yawLabel        = new GUIContent("偏航");
            GUIContent widthLabel      = new GUIContent("宽度");
            GUIContent speedLabel      = new GUIContent("时速");
            Vector2    labelDimension  = GUI.skin.label.CalcSize(rollLabel);
            float      rollWidth       = labelDimension.x + floatFieldWidth;

            r.x += r.width + hSpace; r.width = rect.width - (r.width + hSpace + rollWidth) - (r.height + hSpace);
            EditorGUI.PropertyField(r, element.FindPropertyRelative(() => def.position), GUIContent.none);//位置

            r.x += r.width + hSpace; r.width = rollWidth;
            float oldWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = labelDimension.x;

            var indent = EditorGUI.indentLevel;

            //EditorGUI.indentLevel = 0;
            EditorGUI.PropertyField(r, element.FindPropertyRelative(() => def.roll), rollLabel);
            //EditorGUIUtility.labelWidth = oldWidth;
            //EditorGUI.indentLevel = indent;

            r.y += EditorGUIUtility.singleLineHeight + hSpace;
            EditorGUI.PropertyField(r, element.FindPropertyRelative(() => def.yaw), yawLabel);

            r.x = rect.x + numberDimension.x * 2; r.width = rollWidth + labelDimension.x;
            EditorGUI.PropertyField(r, element.FindPropertyRelative(() => def.speed), speedLabel);

            r.x += r.width + hSpace * 2;
            EditorGUI.PropertyField(r, element.FindPropertyRelative(() => def.width), widthLabel);
        }
        /// <summary>
        /// 插入路径点
        /// </summary>
        /// <param name="indexA"></param>
        void InsertWaypointAtIndex(int indexA)
        {
            Vector3 pos  = Vector3.right;
            float   roll = 0;

            // Get new values from the current indexA (if any)
            int numWaypoints = Target.m_Waypoints.Length;

            if (indexA < 0)
            {
                indexA = numWaypoints - 1;
            }
            if (indexA >= 0)
            {
                int indexB = indexA + 1;
                if (Target.m_Looped && indexB >= numWaypoints)
                {
                    indexB = 0;
                }
                if (indexB >= numWaypoints)
                {
                    Vector3 delta = Vector3.right;
                    if (indexA > 0)
                    {
                        delta = Target.m_Waypoints[indexA].position - Target.m_Waypoints[indexA - 1].position;
                    }
                    pos  = Target.m_Waypoints[indexA].position + delta;
                    roll = Target.m_Waypoints[indexA].roll;
                }
                else
                {
                    // Interpolate
                    pos  = Target.transform.InverseTransformPoint(Target.EvaluatePosition(0.5f + indexA));
                    roll = Mathf.Lerp(Target.m_Waypoints[indexA].roll, Target.m_Waypoints[indexB].roll, 0.5f);
                }
            }
            Undo.RecordObject(Target, "增加路径点");
            var wp = new CinemachineSmoothPathForCarDrift.Waypoint();

            wp.position = pos;
            wp.roll     = roll;
            var list = new List <CinemachineSmoothPathForCarDrift.Waypoint>(Target.m_Waypoints);

            list.Insert(indexA + 1, wp);
            Target.m_Waypoints = list.ToArray();
            Target.InvalidateDistanceCache();
            InspectorUtility.RepaintGameView();
            mWaypointList.index = indexA + 1; // select it
        }
        void DrawPositionControl(int i, Matrix4x4 localToWorld, Quaternion localRotation)
        {
            CinemachineSmoothPathForCarDrift.Waypoint wp = Target.m_Waypoints[i];
            Vector3 pos = localToWorld.MultiplyPoint(wp.position);

            EditorGUI.BeginChangeCheck();
            Handles.color = Target.m_Appearance.pathColor;
            Quaternion rotation = (UnityEditor.Tools.pivotRotation == PivotRotation.Local)
                ? localRotation : Quaternion.identity;
            float size = HandleUtility.GetHandleSize(pos) * 0.1f;

            Handles.SphereHandleCap(0, pos, rotation, size, EventType.Repaint);
            pos = Handles.PositionHandle(pos, rotation);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Move Waypoint");
                wp.position           = Matrix4x4.Inverse(localToWorld).MultiplyPoint(pos);
                Target.m_Waypoints[i] = wp;
                Target.InvalidateDistanceCache();
                InspectorUtility.RepaintGameView();
            }
        }