using UnityEngine; using System.Collections; public class RegisterNameButtonHandler : MonoBehaviour { public UILabel Label; public GameObject UIWarning; void Start() { UIWarning.SetActive(false); } void OnClick() { if (Label.text == string.Empty || Label.text == "Namn...") { UIWarning.SetActive(true); } else { ServerGiftManager.Instance.RegisterSantaName(Label.text, state => { Debug.Log(state); switch (state) { case ServerGiftManager.RegistrationStates.UpdateDone: Debug.Log("UpdateDone"); //todo: handle - user info was updated (everything goes good) break; case ServerGiftManager.RegistrationStates.Old: Debug.Log("Old"); //todo: handle - old user returns (everything goes good) break; case ServerGiftManager.RegistrationStates.SantaNameNotUnique: Debug.Log("SantaNameNotUnique"); //todo: handle - user should guess another name for santa (no data was updated!) break; case ServerGiftManager.RegistrationStates.IdentificatorNotIsset: Debug.Log("IdentificatorNotIsset"); //todo: handle - you must run base registration first! (no data was updated!) break; case ServerGiftManager.RegistrationStates.ContactsIsNotEnough: Debug.Log("ContactsIsNotEnough"); //todo: handle - santaName or phone or e-mail is empty (no data was updated!) break; case ServerGiftManager.RegistrationStates.Error: Debug.Log("Error"); //todo: handle - unknown error happens - maybe internet connection errors (no data was updated!) break; } transform.parent.GetComponent().Hide(); Debug.LogWarning(state); }); } } }