Skip to content

Commit

Permalink
Instantly scroll up
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianGlawogger committed Feb 20, 2025
1 parent 95dbd32 commit a5d5394
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using GEAR.Localization.Text;
using Maroon.GlobalEntities;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

Expand All @@ -22,12 +21,12 @@ public class scrMenuColumnLaboratorySelectionDetail : MonoBehaviour

[SerializeField] private GameObject ExperimentButtonPrefab;

private IEnumerator Start()
private void Start()
{
// Do not init anything if no category is selected, because no lab can be built and no experiments will show up
if(SceneManager.Instance.ActiveSceneCategory == null)
{
yield break;
return;
}

// Update Title
Expand Down Expand Up @@ -63,10 +62,12 @@ private IEnumerator Start()
Maroon.GlobalEntities.SceneManager.Instance.LoadSceneRequest(current_scene));
}

// Force update canvases, to ensure scene buttons have been properly added
Canvas.ForceUpdateCanvases();

// Fully scroll up
yield return null; // Wait a frame for scrollRect to get updated
ScrollRect experimentsScrollRect = ExperimentButtonsContainer.GetComponentInParent<ScrollRect>();
experimentsScrollRect.verticalScrollbar.value = 1;
experimentsScrollRect.verticalNormalizedPosition = 1f;
}

private void OnClickGo()
Expand Down

0 comments on commit a5d5394

Please sign in to comment.