|
|
@@ -9,7 +9,7 @@ namespace CustomUIView
|
|
|
{
|
|
|
[SerializeField] Transform boxSelectDevices;
|
|
|
[SerializeField] GameObject[] boxDevices;
|
|
|
- readonly string[] SelectDevicesStrs = { "ARTEMIS Pro", "Pistol M9", "HOUYI Pro" };
|
|
|
+ readonly string[] SelectDevicesStrs = { "ARTEMIS Pro", "Pistol", "HOUYI Pro" };
|
|
|
int selectDevicesIndex = 0; // 用于保存当前选择的设备索引
|
|
|
// Start is called before the first frame update
|
|
|
void Start()
|
|
|
@@ -22,16 +22,24 @@ namespace CustomUIView
|
|
|
string deviceName = SelectDevicesStrs[i]; // 捕获当前的设备名称
|
|
|
button.onClick.AddListener(() =>
|
|
|
{
|
|
|
- OnClick_SelectDevice(deviceName);
|
|
|
+ //OnClick_SelectDevice(deviceName);
|
|
|
});
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ public void OnEnable()
|
|
|
+ {
|
|
|
+ FlushDeviceSelect();
|
|
|
+ SerialPortHelper.ins.GetPort()?.RequestDeviceIno();//每次打开拉取一次设备信息
|
|
|
+ }
|
|
|
+
|
|
|
+ public void FlushDeviceSelect()
|
|
|
+ {
|
|
|
// 获取用户设置中保存的设备名称
|
|
|
string selectDeviceName = UserSettings.ins.selectDevicesName;
|
|
|
|
|
|
// 如果名称存在于数组中,则获取其索引,否则默认选第一个
|
|
|
selectDevicesIndex = System.Array.IndexOf(SelectDevicesStrs, selectDeviceName);
|
|
|
- if (selectDevicesIndex < 0) selectDevicesIndex = 0;
|
|
|
-
|
|
|
// 渲染选择的设备
|
|
|
RenderSelectDevicesIndex(selectDevicesIndex);
|
|
|
}
|