public void PuzzletConnectionStateChanged(PuzzletConnection.State lastState, PuzzletConnection.State state) { if(state == PuzzletConnection.State.Connected) StartCoroutine(CheckVersion()); if(state == PuzzletConnection.State.Disconnected && lastState == PuzzletConnection.State.Connected) updatePrompt.SetActive(false); }
public void PuzzletConnectionStateChanged(PuzzletConnection.State lastState, PuzzletConnection.State state) { Debug.Log("PuzzletConnection last state: " + lastState + ". New state: " + state); interactionTimeoutPrompt.SetActive(false); bool showNewState = true; //hiding searching/connecting loop if (lastState == PuzzletConnection.State.Handshaking && state == PuzzletConnection.State.Disconnected) { ++handshakeRepeats; } if (handshakeRepeats > 0) { if (state == PuzzletConnection.State.Handshaking || state == PuzzletConnection.State.Disconnected) { showNewState = false; } else { handshakeRepeats = 0; handshakeRepeatText.SetActive(false); } if (handshakeRepeats > handshakeRepeatsToHide) { handshakeRepeatText.SetActive(true); } } //checking if no tray found in a reasonable time frame (see also Update) #if !(UNITY_STANDALONE || UNITY_EDITOR) if (state == PuzzletConnection.State.Disconnected) { noTrayFoundTime = 0; } else { TrayFound(); } #endif //enabling/disabling the display StopAllCoroutines(); if (state == PuzzletConnection.State.Connected) { firmwareVersionText.text = PuzzletUtility.FirmwareString().Substring(0, 5); StartCoroutine(this.Disable()); } else { root.SetActive(true); rootAnim.SetActive(true); } //updating contents of display if (showNewState) { for (int a = 0; a < texts.Length; ++a) { texts[a].SetActive(false); } texts[(int)state].SetActive(true); string triggerName = "NO_TRIGGER"; #if UNITY_STANDALONE || UNITY_EDITOR if (state == PuzzletConnection.State.Disconnected) { triggerName = "ConnectUSB"; } else if (state == PuzzletConnection.State.Handshaking) { triggerName = "ConnectingUSB"; } else if (state == PuzzletConnection.State.Connected) { triggerName = "ConnectedUSB"; } #else if (state == PuzzletConnection.State.Disconnected) { triggerName = "ConnectBluetooth"; } else if (state == PuzzletConnection.State.Handshaking) { triggerName = "ConnectingBluetooth"; } else if (state == PuzzletConnection.State.Connected) { triggerName = "ConnectedBluetooth"; } #endif /*if(state == PuzzletConnection.State.Disconnected) * triggerName = "ConnectBluetooth"; * else if (state == PuzzletConnection.State.Handshaking) * triggerName = "ConnectingBluetooth"; * else if(state == PuzzletConnection.State.Connected) * triggerName = "ConnectedBluetooth";*/ Debug.Log("Connection Status Animation Triggered: " + triggerName); anim.SetTrigger(triggerName); } //text in/out if (state == PuzzletConnection.State.Connected) { textAnim.SetTrigger("ScaleOut"); } else { textAnim.SetTrigger("ScaleIn"); } tooFarTimes = 0; }