public void OnInputClicked(InputClickedEventData eventData) { //Debug.LogFormat("OnInputClicked\r\nSource: {0} SourceId: {1} TapCount: {2}", eventData.InputSource, eventData.SourceId, eventData.TapCount); WasIClicked = !WasIClicked; if (WasIClicked == true) { DimmerActuator a = (DimmerActuator)ItemManager.getInstance().getItem(Settings.Dimmer1); StartCoroutine(a.sendON()); } else { DimmerActuator a = (DimmerActuator)ItemManager.getInstance().getItem(Settings.Dimmer1); StartCoroutine(a.sendOFF()); } }
void Update() { //if (isSelected || isFocused) //{ // cubeMeshRenderer.material = style.highlightMat; //} //else //{ // cubeMeshRenderer.material = cubeDefaultMat; //} if (this.c != null) { updateCounter++; colorUpdateCounter++; if (updateCounter >= Settings.requestUpdateNumber) { if (c.connState.Equals(Connection.States.Active)) { Item source = ItemManager.getInstance().getItem(SourceName); Item target = ItemManager.getInstance().getItem(TargetName); if (source is Poti && target is DimmerActuator) { Poti sPoti = (Poti)source; DimmerActuator tDimmer = (DimmerActuator)target; int stateDim = int.Parse(tDimmer.state); int statePoti = int.Parse(sPoti.state); if (statePoti == 0) { StartCoroutine(tDimmer.sendOFF()); } else if (statePoti == 100) { StartCoroutine(tDimmer.sendON()); } else if (stateDim <= (statePoti - 10)) { StartCoroutine(tDimmer.sendINCREASE()); } else if (stateDim >= (statePoti + 10)) { StartCoroutine(tDimmer.sendDECREASE()); } } else { if (source is Poti && target is HueDimmer) { Poti sPoti = (Poti)source; HueDimmer hDimmer = (HueDimmer)target; StartCoroutine(hDimmer.sendState(sPoti.state)); } else { if (source is ColorSensor && target is HueDimmer) { if (colorUpdateCounter >= 100) { byte r, g, b; ColorSensor cs = (ColorSensor)source; r = Convert.ToByte(cs.r); g = Convert.ToByte(cs.g); b = Convert.ToByte(cs.b); float h, s, v; Color32 colRgb = new Color32(r, g, b, 255); Color.RGBToHSV(colRgb, out h, out s, out v); HueDimmer hDimmer = (HueDimmer)target; int hr = (int)(h * 360); int sr = (int)(s * 100); int vr = (int)(v * 100); StartCoroutine(hDimmer.sendColor(hr, sr, vr)); colorUpdateCounter = 0; } } } } } updateCounter = 0; } } }