// Use this for initialization void Start() { PartTypes = new Dictionary <PartTypeEnum, PartType>(); IotDeviceTypes = new Dictionary <IotDeviceTypeEnum, IotDeviceType>(); //suppose is to load from database PartType p = new PartType(PartTypeEnum.Bearing, "轴承", "Sprites/Picture/MachineDailyMaintance/Bearing"); PartTypes.Add(PartTypeEnum.Bearing, p); p = new PartType(PartTypeEnum.LinearGuide, "线性导轨", "Sprites/Picture/MachineDailyMaintance/Linear_Guide"); PartTypes.Add(PartTypeEnum.LinearGuide, p); p = new PartType(PartTypeEnum.Belt, "皮带", "Sprites/Picture/MachineDailyMaintance/Belt"); PartTypes.Add(PartTypeEnum.Belt, p); IotDeviceType d = new IotDeviceType(IotDeviceTypeEnum.ServoMotor, "伺服电机", "Sprites/Picture/OnlineAna/ServoMotor", "Sprites/SubOnlineAna/ServoMotor"); IotDeviceTypes.Add(d.DeviceType, d); d = new IotDeviceType(IotDeviceTypeEnum.Sensor, "传感器", "Sprites/Picture/OnlineAna/Sensor", "Sprites/SubOnlineAna/Sensor"); IotDeviceTypes.Add(d.DeviceType, d); d = new IotDeviceType(IotDeviceTypeEnum.Solenoid, "电磁阀", "Sprites/Picture/OnlineAna/Solenoid", "Sprites/SubOnlineAna/Solenoid"); IotDeviceTypes.Add(d.DeviceType, d); }
private void OnIotTypeClick(IotDeviceType deviceType) { GameObject curvePage = transform.parent.Find("IotCurvePage").gameObject; IotCurvePageController ctrl = curvePage.GetComponent <IotCurvePageController>(); ctrl.iotDevices = iotDevices.Where((p) => { return(p.DeviceType == deviceType.DeviceType); }).ToList(); NavigationService.Instance.NavigateTo(curvePage); }
private void OnEnable() { if (curveButtons == null) { curveButtons = transform.GetComponentsInChildren <CurveButtonControl>().ToList(); } if (curveViews == null) { curveViews = transform.GetComponentsInChildren <CurveViewControl>().ToList(); } List <string> curveTypes = iotDevices[0].Curves.Select((p) => p.CurveName).ToList(); for (int i = 0; i < curveButtons.Count; i++) { CurveButtonControl button = curveButtons[i]; button.OnCurveTypeClick += OnCurveTypeClick; if (i < curveTypes.Count) { button.CurveType = curveTypes[i]; button.gameObject.SetActive(true); } } for (int i = curveTypes.Count; i < curveButtons.Count; i++) { CurveButtonControl button = curveButtons[i]; button.gameObject.SetActive(false); } OnCurveTypeClick(curveTypes[0]); //load the background picture if (backgroundImage == null) { backgroundImage = transform.Find("Title").GetComponent <Image>(); } if (iotDevices.Count > 0) { IotDeviceType dt = DataManager.IotDeviceTypes[iotDevices[0].DeviceType]; backgroundImage.sprite = Resources.Load <Sprite>(dt.TypeTitleUrl); } }
// Use this for initialization void Start() { iotDevices = new List <IotDevice>(); LoadIotDevices(); typeControls = transform.GetComponentsInChildren <IotDeviceTypeViewControl>().ToList(); for (int i = 0; i < DataManager.IotDeviceTypes.Count; i++) { IotDeviceType iotDeviceType = DataManager.IotDeviceTypes.Values.ToList()[i]; typeControls[i].TheType = iotDeviceType; typeControls[i].OnIotTypeClick += OnIotTypeClick; } }