From a8b5d3ed7f88ed6fe98df924259653a4dcc42d70 Mon Sep 17 00:00:00 2001 From: Braedon Date: Thu, 17 Feb 2022 21:57:35 -0500 Subject: [PATCH] Fixed timeline event's not being rendered if their start and end points are outside of the view. Thank you to chrislo27 for suggesting a fix to this. --- Assets/Scripts/LevelEditor/Timeline/Timeline.cs | 2 +- .../Scripts/LevelEditor/Timeline/TimelineEventObj.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs index f4946664..7af5c5b1 100644 --- a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs +++ b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs @@ -64,7 +64,7 @@ namespace RhythmHeavenMania.Editor.Track [SerializeField] private RectTransform TimelineSlider; [SerializeField] private RectTransform TimelineGridSelect; [SerializeField] private TMP_Text TimelinePlaybackBeat; - [SerializeField] private RectTransform TimelineContent; + public RectTransform TimelineContent; [SerializeField] private RectTransform TimelineSongPosLineRef; [SerializeField] private RectTransform TimelineEventObjRef; [SerializeField] private RectTransform LayersRect; diff --git a/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs b/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs index 60911f7f..b880980e 100644 --- a/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs +++ b/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs @@ -81,8 +81,17 @@ namespace RhythmHeavenMania.Editor.Track #region Optimizations - // problem with long objects but im lazy right now + // thank you to @chrislo27 for suggesting the fix for this. + // only renders blocks if they're in view of the timeline viewport bool visible = rectTransform.IsVisibleFrom(Editor.instance.EditorCamera); + var leftSide = rectTransform.localPosition.x; + var rightSide = leftSide + rectTransform.sizeDelta.x; + + var timelineLeftSide = (Timeline.instance.TimelineContent.localPosition.x / 100f) * -1; + var timelineRightSide = timelineLeftSide + 10.563f; // what a magic number, i'm sure I could calculate this but I'm lazy + + visible = (rightSide >= timelineLeftSide && leftSide <= timelineRightSide); + if (visible != lastVisible) {