예제 #1
0
    protected override void OnDrawScene(SceneView scene)
    {
        Waypoint  keyframe = Target;
        Crazyflie drone    = keyframe.Drone;

        CrazyflieEditor.Draw(drone);
        Vector3 position = GlobalTransform.Transfomed(keyframe.Position);

        if (keyframe.JointType != JointType.Linear)
        {
            DrawTangent(keyframe, false);
            DrawTangent(keyframe, true);
        }

        if (targetPoint == 0)
        {
            CustomHandles.DrawCircle(position, 0.0375f, Color.yellow);
            MoveHandle(keyframe, position, 0.06f, 0.045f, keyframe.SetPosition);
        }
        else
        {
            CustomHandles.DrawCircle(position, 0.0375f, Color.white);
        }

        if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Delete)
        {
            drone.RemoveWaypoint(Target);
        }


        // -- GUI -- //
        DrawGUI(keyframe);
    }
예제 #2
0
    private static void DrawWaypointTools(Waypoint waypoint)
    {
        Crazyflie drone = waypoint.Drone;

        EditorGUI.BeginChangeCheck();
        float updatedTime = EditorGUILayout.FloatField("Time (seconds)", (float)waypoint.time);

        JointType updatedJointType = (JointType)EditorGUILayout.EnumPopup("Joint Type", waypoint.JointType);

        EditorGUILayout.Space(10);

        Vector3 updatedPosition = EditorGUILayout.Vector3Field(new GUIContent("Position"), waypoint.Position);

        EditorGUILayout.Space(10);

        GUI.enabled = (updatedJointType == JointType.Continuous);
        Vector3 updatedTangent = EditorGUILayout.Vector3Field(new GUIContent("Tangent"), waypoint.Tangent);

        EditorGUILayout.Space(30);
        GUI.enabled = true;

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(waypoint, "Change Waypoint");
            waypoint.time      = Mathf.Max(0, updatedTime);
            waypoint.Position  = updatedPosition;
            waypoint.Tangent   = updatedTangent;
            waypoint.JointType = updatedJointType;
            drone.UpdateView();
            TimelineEditor.Refresh(RefreshReason.ContentsModified);
        }

        if (GUILayout.Button("Delete"))
        {
            drone.RemoveWaypoint(waypoint);
        }
    }