diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab index 63d5cce..2d88ca6 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab +++ b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Preferb/UDPClientInstance.prefab @@ -1126,7 +1126,18 @@ MonoBehaviour: m_TargetGraphic: {fileID: 3357100995107918398} m_OnClick: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 1657411067143300629} + m_MethodName: sendMsg + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!1 &3357100995867598124 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs index 9b26dbb..8ee32f6 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs +++ b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/Script/UDPClientView.cs @@ -26,21 +26,15 @@ namespace JXSoft { private string UDPAddress; private int UDPPort; - private int deviceId; private UDPUtility udpUtil; public Transform udpMsgContent; public GameObject udpMsgItem; - public InputField InputSendMsg; - // Start is called before the first frame update - void Awake() - { - initUDPService(); - DontDestroyOnLoad(this); - } + void Start() { udpUtil = GetArchitecture().GetUtility(); + initUDPService(); } // Update is called once per frame @@ -73,29 +67,23 @@ namespace JXSoft { public void initUDPService() { - UDPAddress = "127.0.0.1"; - UDPPort = 20000; - deviceId = 1; - - GetArchitecture().RegisterEvent(e => { - if (e.state == UDPLinkState.Linking) - { - Debug.Log("UDP开始链接"); - this.GetModel().linkServer(); - } - if (e.state == UDPLinkState.LinkSucess) - { - Debug.Log("UDP链接成功"); - onUDPLinkSuccess.Invoke(); - } - if (e.state == UDPLinkState.LinkFaild) - { - Debug.Log("UDP连接失败,请联系设备服务管理员"); - onUDPLinkFaild.Invoke(); - } + UDPAddress = "192.168.1.41"; + UDPPort = 52101; + this.RegisterLinkStateEvent((int)UDPLinkState.Linking, () => { + Debug.Log("UDP开始链接"); + this.GetModel().linkServer(); + }); + this.RegisterLinkStateEvent((int)UDPLinkState.LinkSucess, () => + { + Debug.Log("UDP链接成功"); + onUDPLinkSuccess.Invoke(); + }); + this.RegisterLinkStateEvent((int)UDPLinkState.LinkFaild, () => + { + Debug.Log("UDP连接失败,请联系设备服务管理员"); + onUDPLinkFaild.Invoke(); }); - this.GetModel().setLinkState((int)UDPLinkState.NoIp); this.GetModel().setIP(UDPAddress, UDPPort); }