private void OnDestroy() { _inputNameRole = null; EventCenter.UnRegisterButtonEvent("RegisRole-role1"); EventCenter.UnRegisterButtonEvent("RegisRole-role2"); EventCenter.UnRegisterButtonEvent("RegisRole-role3"); EventCenter.UnRegisterButtonEvent("RegisRole-role4"); EventCenter.UnRegisterButtonEvent("RegisRole-role5"); EventCenter.UnRegisterButtonEvent("RegisRole-Login"); EventCenter.UnRegisterButtonEvent("RegisRole-Back"); _buttonRole1 = null; _buttonRole2 = null; _buttonRole3 = null; _buttonRole4 = null; _buttonRole5 = null; _buttonLogRole = null; _buttonBack = null; _networkClient.Off(CmdManager.RegisRole, SocketIORegisRole); _networkClient.Off(CmdManager.GetRole, SocketIOGetRole); _networkClient = null; }
private void Start() { _networkClient = NetworkClient._instance; _inputNameRole = transform.Find("Control - Simple Input Field").GetComponent <UIInput>(); _buttonRole1 = EventCenter.RegisterButtonEvent("RegisRole-role1", new RegisRole_RoleExcute()) as RegisRole_RoleExcute; _buttonRole1.data.Add("id", 1); _buttonRole2 = EventCenter.RegisterButtonEvent("RegisRole-role2", new RegisRole_RoleExcute()) as RegisRole_RoleExcute; _buttonRole2.data.Add("id", 2); _buttonRole3 = EventCenter.RegisterButtonEvent("RegisRole-role3", new RegisRole_RoleExcute()) as RegisRole_RoleExcute; _buttonRole3.data.Add("id", 3); _buttonRole4 = EventCenter.RegisterButtonEvent("RegisRole-role4", new RegisRole_RoleExcute()) as RegisRole_RoleExcute; _buttonRole4.data.Add("id", 4); _buttonRole5 = EventCenter.RegisterButtonEvent("RegisRole-role5", new RegisRole_RoleExcute()) as RegisRole_RoleExcute; _buttonRole5.data.Add("id", 5); _buttonLogRole = EventCenter.RegisterButtonEvent("RegisRole-Login", new RegisRole_LoginExcute()) as RegisRole_LoginExcute; _buttonBack = EventCenter.RegisterButtonEvent("RegisRole-Back", new RegisRole_BackExcute()) as RegisRole_BackExcute; OnClickRole(1); _networkClient.On(CmdManager.RegisRole, SocketIORegisRole); _networkClient.On(CmdManager.GetRole, SocketIOGetRole); }