Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System;
- using UnityEngine.UI;
- public class GameManager : MonoBehaviour {
- public static string PlayerName, PlayerSchool;
- public static long PlayerID;
- public static int PlayerScore;
- public int IdSize = 0;
- public int ApplicationLevel;
- public GameObject InputName;
- public GameObject InputID;
- public GameObject InputSchoolName;
- // Use this for initialization
- void Start()
- {
- PlayerName = "";
- PlayerID = 0;
- PlayerSchool = "";
- }
- public void OnClick()
- {
- string tempID = InputID.GetComponent<Text>().text;
- bool isNumeric = long.TryParse(tempID, out PlayerID);
- long InputNameLength = InputName.GetComponent<Text>().text.Length;
- long InputSchoolLenth = InputSchoolName.GetComponent<Text>().text.Length;
- // Validation
- if (isNumeric && tempID.Length == IdSize && InputNameLength > 0 && InputSchoolLenth > 0 && InputName.GetComponent<Text>().text != "Please Type in Correct Format" && InputSchoolName.GetComponent<Text>().text != "Please Type in Correct Format")
- {
- PlayerID = Convert.ToInt64(tempID);
- PlayerName = InputName.GetComponent<Text>().text;
- PlayerSchool = InputSchoolName.GetComponent<Text>().text;
- Application.LoadLevel(ApplicationLevel);
- }
- if (tempID.Length > IdSize || tempID.Length < IdSize || !isNumeric || InputID.GetComponent<Text>().text == "Please Type Correct ID")
- {
- InputID.GetComponent<Text>().text = "Please Type Correct ID";
- InputID.GetComponent<Text>().color = Color.red;
- }
- if (InputNameLength == 0 || InputName.GetComponent<Text>().text == "Please Type in Correct Format" )
- {
- InputName.GetComponent<Text>().text = "Please Type in Correct Format";
- InputName.GetComponent<Text>().color = Color.red;
- }
- if (InputSchoolLenth == 0 || InputSchoolName.GetComponent<Text>().text == "Please Type in Correct Format")
- {
- InputSchoolName.GetComponent<Text>().text = "Please Type in Correct Format";
- InputSchoolName.GetComponent<Text>().color = Color.red;
- }
- Debug.Log(PlayerName);
- Debug.Log(PlayerID);
- Debug.Log(PlayerSchool);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement