From a667f4f8f7e628d9faa77bcd633601b584dc2013 Mon Sep 17 00:00:00 2001 From: minenice55 Date: Tue, 9 Apr 2024 09:26:12 -0400 Subject: [PATCH] exclude non packed games from the preload check (#849) don't make multiple timeline playheads --- Assets/Scripts/GameManager.cs | 2 +- .../Scripts/LevelEditor/Timeline/Timeline.cs | 67 +++---------------- 2 files changed, 11 insertions(+), 58 deletions(-) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index e630566e..57c34e61 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -1020,7 +1020,7 @@ namespace HeavenStudio if (canPreload) { Minigames.Minigame inf = GetGameInfo(newGame); - if (inf != null) + if (inf != null && inf.usesAssetBundle && !inf.AssetsLoaded) { preload.Add(inf); } diff --git a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs index 2b4039ce..b8374e5c 100644 --- a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs +++ b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs @@ -165,7 +165,6 @@ namespace HeavenStudio.Editor.Track public TMP_InputField StartingVolumeSpecialVolume; public SpecialTimeline SpecialInfo; - private RectTransform TimelineSongPosLine; [Header("Timeline Playbar")] public Button PlayBTN; @@ -250,6 +249,7 @@ namespace HeavenStudio.Editor.Track TimelineSlider.GetChild(2).GetComponent().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB(); TimelineSlider.GetChild(3).GetComponent().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB(); TimelineSongPosLineRef.GetComponent().color = EditorTheme.theme.properties.CurrentTimeMarkerCol.Hex2RGB(); + TimelineSongPosLineRef.gameObject.SetActive(false); PlayBTN.onClick.AddListener(delegate { @@ -408,55 +408,10 @@ namespace HeavenStudio.Editor.Track } } - /* - if (MouseInTimeline) - { - var wheel = Input.mouseScrollDelta.y; - - if (wheel != 0) - { - var incre = 0.0f; - if (wheel > 0) - { - incre += wheel * (Zoom * 0.25f); - } - else - { - incre += wheel * (Zoom * 0.2f); - } - - var v = new Vector3[4]; - TimelineScroll.viewport.GetWorldCorners(v); - var viewportPos = Editor.instance.EditorCamera.WorldToScreenPoint(v[0]); - - var left = leftSide; - var viewportWidth = TimelineScroll.viewport.rect.width; - var localPointRec = Mathf.Lerp(left, left + (viewportWidth / Zoom), - MathUtils.Normalize(Input.mousePosition.x, viewportPos.x, viewportPos.x + viewportWidth)); - - var xPixels = (localPointRec * incre); - xPixels *= (Zoom); - - TimelineContent.anchoredPosition = new Vector2( - TimelineContent.anchoredPosition.x - xPixels, - TimelineContent.anchoredPosition.y - ); - - Zoom += incre; - Zoom = Mathf.Clamp(Zoom, 1, 1000); - } - } - */ - MousePos2Beat = relativeMousePos.x / PixelsPerBeat; MousePos2Layer = Mathf.Clamp(Mathf.FloorToInt(-(relativeMousePos.y) / LayerHeight()), 0, LayerCount - 1); Conductor cond = Conductor.instance; - // waveform.rectTransform.anchoredPosition = new Vector2( - // -(GameManager.instance.Beatmap.data.offset / (60.0f / GameManager.instance.Beatmap.bpm)), - // waveform.rectTransform.anchoredPosition.y); - - // WaveformBTN.transform.GetChild(0).GetComponent().color = (cond.musicSource.clip != null && waveform.gameObject.activeInHierarchy) ? Color.white : Color.gray; if (!cond.isPlaying && !cond.isPaused) { @@ -631,9 +586,13 @@ namespace HeavenStudio.Editor.Track { TimelinePlaybackBeat.text = $"Beat {string.Format("{0:0.000}", PlaybackBeat)}"; - if (TimelineSongPosLine != null && !Conductor.instance.WaitingForDsp) + if (TimelineSongPosLineRef != null && !Conductor.instance.WaitingForDsp) { - TimelineSongPosLine.transform.localPosition = new Vector3(Conductor.instance.songPositionInBeats * PixelsPerBeat, TimelineSongPosLine.transform.localPosition.y); + if (Conductor.instance.isPlaying && !TimelineSongPosLineRef.gameObject.activeSelf) + { + TimelineSongPosLineRef.gameObject.SetActive(true); + } + TimelineSongPosLineRef.transform.localPosition = new Vector3(Conductor.instance.songPositionInBeats * PixelsPerBeat, TimelineSongPosLineRef.transform.localPosition.y); } } @@ -677,9 +636,7 @@ namespace HeavenStudio.Editor.Track GameManager.instance.SafePlay(time, 0, false); if (!Conductor.instance.isPaused) { - TimelineSongPosLine = Instantiate(TimelineSongPosLineRef, TimelineSongPosLineRef.parent).GetComponent(); - TimelineSongPosLine.gameObject.SetActive(true); - TimelineSongPosLine.transform.localPosition = new Vector3(time * PixelsPerBeat, TimelineSongPosLine.transform.localPosition.y); + TimelineSongPosLineRef.transform.localPosition = new Vector3(time * PixelsPerBeat, TimelineSongPosLineRef.transform.localPosition.y); } SetTimeButtonColors(false, true, true); @@ -687,7 +644,6 @@ namespace HeavenStudio.Editor.Track public void Pause() { - // isPaused = true; GameManager.instance.Pause(); SetTimeButtonColors(true, false, true); @@ -695,11 +651,8 @@ namespace HeavenStudio.Editor.Track public void Stop(float time) { - // isPaused = true; - // timelineSlider.value = 0; - - if (TimelineSongPosLine != null) - Destroy(TimelineSongPosLine.gameObject); + if (TimelineSongPosLineRef != null) + TimelineSongPosLineRef.gameObject.SetActive(false); GameManager.instance.Stop(time);