public static GameObject MapSc; //todo 使用gameobject.find方法一直找不到main,先暂时通过ui界面获取 void Start() { MapSc = mapSc; Game.Instance.Status = GameStatus.Login; // 注册obj GameObject root = GameObject.Find("Login"); var loginError = root.transform.Find("Login/Error").gameObject; GameObjmgr.Register("loginError", loginError); var regError = root.transform.Find("Register/Error").gameObject; GameObjmgr.Register("regError", regError); //注册按钮 var btn = root.transform.Find("Login/Button").GetComponent <Button>(); btn.onClick.AddListener(BtnLogin); var btn1 = root.transform.Find("Login/BtnReg").GetComponent <Button>(); btn1.onClick.AddListener(BtnToReg); var Rbtn = root.transform.Find("Register/Button").GetComponent <Button>(); Rbtn.onClick.AddListener(BtnReg); var btnReturn = root.transform.Find("Register/BtnReturn").GetComponent <Button>(); btnReturn.onClick.AddListener(BtnToLogin); // 注册 输入文本 var account = root.transform.Find("Login/Account").gameObject; var pwd = root.transform.Find("Login/PWD").gameObject; pwd.GetComponent <InputField>().contentType = InputField.ContentType.Password; Inputmgr.Register("account", account); Inputmgr.Register("pwd", pwd); // 注册 输入文本 var raccount = root.transform.Find("Register/Account").gameObject; var rpwd = root.transform.Find("Register/PWD").gameObject; rpwd.GetComponent <InputField>().contentType = InputField.ContentType.Password; var rpwd1 = root.transform.Find("Register/PWD1").gameObject; rpwd1.GetComponent <InputField>().contentType = InputField.ContentType.Password; Inputmgr.Register("raccount", raccount, new Inputmgr.ObjCheckFun() { end = CheckRegAcc, change = CheckRegAcc }); Inputmgr.Register("rpwd", rpwd, new Inputmgr.ObjCheckFun() { end = CheckRegPwd1, change = CheckRegPwd1 }); Inputmgr.Register("rpwd1", rpwd1, new Inputmgr.ObjCheckFun() { end = CheckRegPwd, change = CheckRegPwd }); }
public static void logError(string error) { switch (status) { case STATUS.LOGIN: GameObjmgr.GetObjByName("loginError").GetComponent <Text>().text = error; break; case STATUS.REG: GameObjmgr.GetObjByName("regError").GetComponent <Text>().text = error; break; } }