Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using TMPro;
- using UnityEngine.SceneManagement;
- public class CodeEntryManager : MonoBehaviour
- {
- public InputField codeInputField;
- public Button submitButton;
- public string correctCode = "TESTCODE"; // **Important: Replace with a temporary test code**
- public string nextSceneName = "GameScene"; // Assuming your game scene is named "GameScene"
- void Start()
- {
- if (codeInputField == null || submitButton == null)
- {
- Debug.LogError("One or more UI elements are not assigned in the Inspector!");
- enabled = false;
- return;
- }
- submitButton.onClick.AddListener(CheckCode);
- }
- void CheckCode()
- {
- if (codeInputField.text == correctCode)
- {
- Invoke("LoadNextScene", 1f);
- }
- else
- {
- codeInputField.text = "";
- }
- }
- void LoadNextScene()
- {
- SceneManager.LoadScene(nextSceneName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement