示例#1
0
        /// <summary>
        /// OnSceneGUI, draws repositionable handles at every point in the path, for easier setup
        /// </summary>
        protected virtual void OnSceneGUI()
        {
            Handles.color = Color.green;
            MMPath t = (target as MMPath);

            if (t.GetOriginalTransformPositionStatus() == false)
            {
                return;
            }

            for (int i = 0; i < t.PathElements.Count; i++)
            {
                EditorGUI.BeginChangeCheck();

                Vector3  oldPoint = t.GetOriginalTransformPosition() + t.PathElements[i].PathElementPosition;
                GUIStyle style    = new GUIStyle();

                // draws the path item number
                style.normal.textColor = Color.yellow;
                Handles.Label(t.GetOriginalTransformPosition() + t.PathElements[i].PathElementPosition + (Vector3.down * 0.4f) + (Vector3.right * 0.4f), "" + i, style);

                // draws a movable handle
                Vector3 newPoint = Handles.FreeMoveHandle(oldPoint, Quaternion.identity, .5f, new Vector3(.25f, .25f, .25f), Handles.CircleHandleCap);
                newPoint = ApplyAxisLock(oldPoint, newPoint);

                // records changes
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(target, "Free Move Handle");
                    t.PathElements[i].PathElementPosition = newPoint - t.GetOriginalTransformPosition();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Locks handles movement on x, y, or z axis
        /// </summary>
        /// <param name="oldPoint"></param>
        /// <param name="newPoint"></param>
        /// <returns></returns>
        protected virtual Vector3 ApplyAxisLock(Vector3 oldPoint, Vector3 newPoint)
        {
            MMPath t = (target as MMPath);

            if (t.LockHandlesOnXAxis)
            {
                newPoint.x = oldPoint.x;
            }
            if (t.LockHandlesOnYAxis)
            {
                newPoint.y = oldPoint.y;
            }
            if (t.LockHandlesOnZAxis)
            {
                newPoint.z = oldPoint.z;
            }

            return(newPoint);
        }