Beispiel #1
0
    public static void DrawSelector(Waypoint keyframe, bool showTime = false)
    {
        Vector3 position   = GlobalTransform.Transfomed(keyframe.Position);
        float   size       = 0.025f;
        float   hitboxSize = 1.5f * size;

        // -- DOT -- //
        Handles.color = Color.white;
        Handles.SphereHandleCap(0, position, Quaternion.identity, size, EventType.Repaint);

        // -- SELECTION -- //
        if (CustomHandles.SelectableButton(position, hitboxSize, Color.white))
        {
            Selection.activeObject = keyframe;
            targetPoint            = 0;
        }

        // -- MOVEMENT -- //
        FreeMove(keyframe, position, hitboxSize, CustomHandles.NullCap, keyframe.SetPosition);

        // -- LABEL -- //
        if (showTime)
        {
            string timestamp = $"{keyframe.time.ToString("0.0")} s";
            Handles.Label(position + LabelOffset, timestamp, CustomGUI.LabelStyle);
        }
    }
Beispiel #2
0
    protected static void DrawPointHandles(List <AttachmentPoint> points)
    {
        foreach (AttachmentPoint point in points)
        {
            Vector3 position = point.Position;
            CustomHandles.DrawDisc(position, 0.0075f, Color.white);
            if (CustomHandles.SelectableButton(position, 0.035f, Color.green))
            {
                foreach (AttachmentPoint otherPoint in points)
                {
                    otherPoint.Selected = false;
                }

                point.Selected = true;
            }

            if (point.Selected)
            {
                CustomHandles.DrawCircle(position, 0.035f, Color.white);
                Crazyflie[] drones = GameObject.FindObjectsOfType <Crazyflie>();
                foreach (Crazyflie drone in drones)
                {
                    if (CustomHandles.SelectableButton(drone.transform.position, 0.075f, Color.green))
                    {
                        drone.SetWaypoint(position, drone.Time);
                        point.Drone    = drone;
                        point.Selected = false;
                    }
                }
            }
        }
    }
Beispiel #3
0
    protected void DrawTangent(Waypoint keyframe, bool invert)
    {
        Vector3          position        = GlobalTransform.Transfomed(keyframe.Position);
        Vector3          tangentPosition = GlobalTransform.Transfomed(invert ? keyframe.InverseWorldTangent : keyframe.WorldTangent);
        Action <Vector3> applyFunction   = invert ? (Action <Vector3>)keyframe.SetInverseTangent : keyframe.SetTangent;

        Handles.color = Color.white;
        Handles.SphereHandleCap(0, tangentPosition, Quaternion.identity, 0.01f, EventType.Repaint);

        Handles.color = Palette.Translucent;
        Handles.DrawLine(position, tangentPosition);

        if (CustomHandles.SelectableButton(tangentPosition, 0.015f, Color.white))
        {
            targetPoint = (invert ? 2 : 1);
        }

        // Circle
        FreeMove(keyframe, tangentPosition, 0.015f, CustomHandles.CircleCap, applyFunction);

        // Selected
        if ((!invert && targetPoint == 1) || (invert && targetPoint == 2))
        {
            CustomHandles.DrawCircle(tangentPosition, 0.015f, Color.yellow);
            MoveHandle(keyframe, tangentPosition, 0.04f, 0.025f, applyFunction);
        }
    }
Beispiel #4
0
    public static void DrawSelector(ColorKeyframe keyframe)
    {
        int     hint           = (ControlHint * keyframe.MarkerIndex) + keyframe.MarkerIndex;
        int     controlId      = GUIUtility.GetControlID(hint, FocusType.Passive);
        Vector3 offsetPosition = keyframe.Position + new Vector3(0, keyframe.Offset, 0);

        float size       = 0.0175f;
        float hitboxSize = 1.5f * size;

        // -- DOT & LINE -- //
        Handles.color = Palette.Translucent;
        Handles.DrawLine(keyframe.Position, offsetPosition);
        CustomHandles.DrawDisc(offsetPosition, size * 0.5f, keyframe.LightColor);

        // -- SELECTION -- //
        if (CustomHandles.SelectableButton(offsetPosition, hitboxSize, keyframe.LightColor))
        {
            Selection.activeObject = keyframe;
        }

        bool selected = Selection.activeObject == keyframe;

        if (selected)
        {
            CustomHandles.DrawCircle(offsetPosition, hitboxSize, keyframe.LightColor);
        }


        /// -- MOVEMENT -- //
        EditorGUI.BeginChangeCheck();
        Vector3 newPosition = Handles.FreeMoveHandle(controlId, offsetPosition, Quaternion.identity, size, DefaultSnap, CustomHandles.NullCap);

        if (EditorGUI.EndChangeCheck() && selected)
        {
            Undo.RecordObject(keyframe, "Change Color Keyframe");

            Vector3 delta = (newPosition - offsetPosition);
            ApplyDelta(keyframe, keyframe.Tangent, delta);

            keyframe.Drone.UpdateView();
            TimelineEditor.Refresh(RefreshReason.ContentsModified);
        }
    }