using UnityEngine; using UnityEngine.SceneManagement; public class CursorManager : MonoBehaviour { public string gameplaySceneName = "GameScene"; // nama scene gameplay kamu public string menuSceneName = "MainMenu"; // nama scene main menu kamu void Start() { UpdateCursorState(SceneManager.GetActiveScene().name); // Subscribe supaya tahu kalau scene berubah SceneManager.sceneLoaded += OnSceneLoaded; } void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; } void OnSceneLoaded(Scene scene, LoadSceneMode mode) { UpdateCursorState(scene.name); } void UpdateCursorState(string sceneName) { if (Application.isMobilePlatform) return; // ⛔ Jangan ubah cursor di Android if (sceneName == menuSceneName) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } else if (sceneName == gameplaySceneName) { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } else { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } } }