Пример #1
0
        private void UpdateTimelineSelection()
        {
            float diff = Camera.main.ScreenToWorldPoint(Input.mousePosition).x - dragSelectTimeline.position.x;
            float timelineScaleMulti = Timeline.scale / 20f;

            dragSelectTimeline.localScale = new Vector3(diff * timelineScaleMulti, 1.1f, 1);

            Vector2 topLeft = dragSelectTimeline.transform.TransformPoint(0, 0, 0);
            Vector2 size    = dragSelectTimeline.transform.TransformVector(1, 1, 1);

            Vector2 center = new Vector2(topLeft.x + size.x / 2, topLeft.y - size.y / 2);

            float minX = Math.Min(center.x - size.x / 2, center.x + size.x / 2);
            float maxX = Math.Max(center.x - size.x / 2, center.x + size.x / 2);
            float minY = Math.Min(center.y - size.y / 2, center.y + size.y / 2);
            float maxY = Math.Max(center.y - size.y / 2, center.y + size.y / 2);

            Rect selectionRect = Rect.MinMaxRect(minX, minY, maxX, maxY);

            float         offscreenOffset = timelineNotes.parent.position.x;
            QNT_Timestamp start           = Timeline.time + Relative_QNT.FromBeatTime((minX - offscreenOffset - 1.0f) * timelineScaleMulti);
            QNT_Timestamp end             = Timeline.time + Relative_QNT.FromBeatTime((maxX - offscreenOffset + 1.0f) * timelineScaleMulti);

            if (start > end)
            {
                QNT_Timestamp temp = start;
                start = end;
                end   = temp;
            }

            List <Target> newSelectedTargets = new List <Target>();

            foreach (Target target in new NoteEnumerator(start, end))
            {
                if (target.IsTimelineInsideRect(selectionRect))
                {
                    newSelectedTargets.Add(target);
                }
            }

            var deselectedTargets = dragTimelineSelectedTargets.Except(newSelectedTargets);

            foreach (Target t in deselectedTargets)
            {
                t.MakeTimelineDeselectTarget();
            }

            var selectedTargets = newSelectedTargets.Except(dragTimelineSelectedTargets);

            foreach (Target t in selectedTargets)
            {
                t.MakeTimelineSelectTarget();
            }

            dragTimelineSelectedTargets = newSelectedTargets;
        }
Пример #2
0
        private QNT_Timestamp SnapToBeat(float posX)
        {
            QNT_Timestamp time = Timeline.time + Relative_QNT.FromBeatTime(posX);

            return(timeline.GetClosestBeatSnapped(time + Constants.DurationFromBeatSnap((uint)timeline.beatSnap) / 2, (uint)timeline.beatSnap));
        }