92 lines
2.2 KiB
C#
92 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using DG.Tweening;
|
|
|
|
namespace MMO
|
|
{
|
|
public class MMOUIFill : MMOUIBase
|
|
{
|
|
[SerializeField] CanvasGroup mCvsBg;
|
|
[SerializeField] RectTransform mRctBg;
|
|
|
|
[SerializeField] GameObject mGobMale;
|
|
[SerializeField] GameObject mGobFemale;
|
|
|
|
[SerializeField] InputField mIptUsername;
|
|
|
|
[SerializeField] Button mBtnMale;
|
|
[SerializeField] Button mBtnFemale;
|
|
|
|
[SerializeField] Button mBtnSubmit;
|
|
[SerializeField] Button mBtnClose;
|
|
|
|
private int mSex = 0;
|
|
|
|
protected override void OnInit()
|
|
{
|
|
base.OnInit();
|
|
|
|
BindBtn(mBtnMale, OnClickMale);
|
|
BindBtn(mBtnFemale, OnClickFemale);
|
|
BindBtn(mBtnSubmit, OnClickSubmit);
|
|
BindBtn(mBtnClose, OnClickClose);
|
|
}
|
|
|
|
public override void OnOpen()
|
|
{
|
|
base.OnOpen();
|
|
|
|
mCvsBg.alpha = 0;
|
|
mRctBg.anchoredPosition = new Vector2(-40, -160);
|
|
|
|
mCvsBg.DOFade(1, 0.3f);
|
|
mRctBg.DOAnchorPosY(0, 0.3f);
|
|
|
|
mIptUsername.text = MMOUserData.Instance.Username;
|
|
SetSex(MMOUserData.Instance.Sex);
|
|
}
|
|
|
|
public void SetInput(string pStr)
|
|
{
|
|
mIptUsername.gameObject.SetActive(!string.IsNullOrEmpty(pStr));
|
|
mIptUsername.text = pStr;
|
|
}
|
|
|
|
private void OnClickClose()
|
|
{
|
|
mCvsBg.DOFade(0, 0.3f);
|
|
mRctBg.DOAnchorPosY(-160, 0.3f).onComplete = Close;
|
|
}
|
|
|
|
private void SetSex(int pSex)
|
|
{
|
|
mSex = pSex;
|
|
mGobMale.SetActive(mSex == 1);
|
|
mGobFemale.SetActive(mSex == 0);
|
|
}
|
|
|
|
private void OnClickMale()
|
|
{
|
|
SetSex(1);
|
|
}
|
|
|
|
private void OnClickFemale()
|
|
{
|
|
SetSex(0);
|
|
}
|
|
|
|
private void OnClickSubmit()
|
|
{
|
|
MMOUserData.Instance.Username = mIptUsername.text;
|
|
MMOUserData.Instance.Sex = mSex;
|
|
|
|
MMOModule.Instance.UIMgr.GetUI<MMOUIMain>().UpdateUserInfo();
|
|
|
|
MMOModule.Instance.LogEvent(MMOEvent.NameSubmit);
|
|
|
|
OnClickClose();
|
|
}
|
|
}
|
|
} |