using UnityEngine; using UnityEngine.UI; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; public class HoldToLoadLevel : MonoBehaviour { public float holdTime = 1f; public Image fillCircle; public string hubSceneName = "HubScene"; // Set this to your actual hub scene name private float holdTimer = 0; private bool isHolding = false; void Update() { if (isHolding) { holdTimer += Time.deltaTime; fillCircle.fillAmount = holdTimer / holdTime; if (holdTimer >= holdTime) { // Mark the level as completed if (HubReturnData.lastDoorIndex >= 0) { WorldProgress.levelsCompleted[HubReturnData.lastDoorIndex] = true; } SceneManager.LoadScene(hubSceneName); SoundEffectManager.Play("NextLevel"); ResetHold(); } } } public void OnHold(InputAction.CallbackContext context) { if (context.started) { isHolding = true; } else if (context.canceled) { ResetHold(); } } private void ResetHold() { isHolding = false; holdTimer = 0; fillCircle.fillAmount = 0; } }