123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class ChangeNamePop : MonoBehaviour
- {
- public InputField userNameInput;
- public Text nameRemind;
- public Image inputKuangImage;
- public Button OkBtn;
- public Button returnBtn;
- public Text nameText;
- // Start is called before the first frame update
- void Awake()
- {
- userNameInput.onValueChanged.AddListener(NameValueChanged);
- userNameInput.onEndEdit.AddListener(NameEndEdit);
- OkBtn.onClick.AddListener(ClickOnOkBtn);
- returnBtn.onClick.AddListener(ClickOnCanel);
- }
- public void Init()
- {
- userNameInput.text = "";
- nameRemind.gameObject.SetActive(false);
- ChangeOriginal();
- }
- private void NameEndEdit(string name)
- {
- if (name == "" || name.Contains(" "))
- {
- nameRemind.gameObject.SetActive(true);
- nameRemind.text = RtcStrConfig.namenolegal;
- ChangeRed();
- }
- else
- {
- ChangeOriginal();
- }
- }
- private void NameValueChanged(string name)
- {
- nameRemind.gameObject.SetActive(false);
- ChangeBlue();
- }
- private void ClickOnCanel()
- {
- this.gameObject.SetActive(false);
- }
- private void ClickOnOkBtn()
- {
- if (userNameInput.text != "" && !nameRemind.gameObject.activeSelf)
- {
- nameText.text = userNameInput.text;
- this.gameObject.SetActive(false);
- }
- }
- public void ChangeOriginal()
- {
- Color color = Color.white;
- color.r = 255 / 255f;
- color.g = 255 / 255f;
- color.b = 255 / 255f;
- color.a = 100 / 255f;
- inputKuangImage.color = color;
- }
- public void ChangeBlue()
- {
- Color color = Color.white;
- color.r = 111 / 255f;
- color.g = 168 / 255f;
- color.b = 254 / 255f;
- color.a = 255 / 255f;
- inputKuangImage.color = color;
- }
- public void ChangeRed()
- {
- Color color = Color.white;
- color.r = 254 / 255f;
- color.g = 1 / 255f;
- color.b = 7 / 255f;
- color.a = 255 / 255f;
- inputKuangImage.color = color;
- }
- }
|