using UnityEngine; using System.Collections; public class RenameButtonHandler : MonoBehaviour { public UILabel Label; public MessageCodeCap UIMessage; //public GameObject UIWarning; void Start() { //UIWarning.SetActive(false); } void OnClick() { if (Label.text == string.Empty || Label.text == "Nytt namm...") { //UIMessage.LabelMessage.text = "Felaktigt namn. Försök igen."; // UIMessage.GetComponent().Show(); NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Menu); NGUITools.SetActive(this.transform.parent.gameObject, false); } else { ServerGiftManager.Instance.RegisterSantaName(Label.text, state => { switch (state) { case ServerGiftManager.RegistrationStates.UpdateDone: NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Menu); NGUITools.SetActive(this.transform.parent.gameObject, false); Debug.Log("UpdateDone"); Label.text = "Nytt namm..."; //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: UIMessage.LabelMessage.text = "Tyvärr är namnet redan upptaget"; UIMessage.GetComponent().Show(); Label.text = "Nytt namm..."; Debug.Log("SantaNameNotUnique"); //todo: handle - user should guess another name for santa (no data was updated!) break; case ServerGiftManager.RegistrationStates.IdentificatorNotIsset: Debug.Log("IdentificatorNotIsset"); Label.text = "Nytt namm..."; //todo: handle - you must run base registration first! (no data was updated!) break; case ServerGiftManager.RegistrationStates.ContactsIsNotEnough: Debug.Log("ContactsIsNotEnough"); Label.text = "Nytt namm..."; //todo: handle - santaName or phone or e-mail is empty (no data was updated!) break; case ServerGiftManager.RegistrationStates.Error: UIMessage.LabelMessage.text = "Okänt fel"; UIMessage.GetComponent().Show(); Label.text = "Nytt namm..."; //todo: handle - unknown error happens - maybe internet connection errors (no data was updated!) break; } Debug.LogWarning(state); }); } } }