void Awake() { nu = NativeUart.Instance; nu.OnUartState += SerialState; nu.OnUartDeviceList += SerialDeviceList; nu.OnUartMessageRead += SerialMessageReceived; nu.OnUartMessageReadLine += SerialMessageReceivedLine; nu.Init(); }
void Awake() { try { nu = NativeUart.Instance; deviceList.ClearOptions(); deviceList.onValueChanged.AddListener(index => { devicePath = deviceList.options[index].text; }); baudrateInput.onValueChanged.AddListener(value => { baudrate = int.Parse(value); }); switchPort.onClick.AddListener(SwitchPort); send.onClick.AddListener(SendCommand); clear.onClick.AddListener(() => { logManager.ClearMssage(); }); forbidden.onClick.AddListener(() => { isForbiddenReceive = !isForbiddenReceive; forbidden.GetComponentInChildren <Text>().text = isForbiddenReceive ? "打开禁止自动更新日志" : "关闭禁止自动更新日志"; }); send.interactable = false; tip.SetActive(false); nu.OnUartState += SerialState; nu.OnUartDeviceList += SerialDeviceList; nu.OnUartMessageRead += SerialMessageReceived; nu.Init(); } catch (Exception e) { logManager.AddMessage(LogManager.MessageType.Error, "Initialize serial port error: " + e.Message); } }
void Awake() { nu = NativeUart.Instance; sendButton.interactable = false; connectButton.onClick.AddListener(() => { SerialConnection(); }); sendButton.onClick.AddListener(() => { SerialSend(); }); boudrateInput.onEndEdit.AddListener((string boud) => { boudrate = int.Parse(boud); }); nu.OnUartState += SerialState; nu.OnUartDeviceList += SerialDeviceList; nu.OnUartMessageRead += SerialMessageReceived; nu.OnUartMessageReadLine += SerialMessageReceivedLine; nu.Init(); }