コード例 #1
0
 // Use this for initialization
 void Start()
 {
     mHoloboardController = HoloboardController.Instance;
     TroubleShootScreen.SetActive(false);
     LoadingCircle.SetActive(false);
     PairRequest.SetActive(false);
     LEDImage.enabled = false;
     Button1.SetActive(false);
     ControllerCallbacks.OnControllerStateChanged += ControllerCallbacks_OnControllerStateChanged;
 }
コード例 #2
0
    /// <summary>
    /// Callback for controller state changes
    /// </summary>
    /// <param name="obj">New Controller state</param>
    void ControllerCallbacks_OnControllerStateChanged(CONTROLLER_STATE obj)
    {
        switch (obj)
        {
        case CONTROLLER_STATE.DEVICE_NOT_FOUND:
            TroubleShootScreen.SetActive(false);
            PairRequest.SetActive(false);
            LoadingCircle.SetActive(true);
            InstructionsText.text = "Connecting.. \n\nPlease Ensure The Blue Light Is Blinking On The Connector \n\nPlease Press The Controller Button Once Again";
            StartCoroutine(BlinkLED());
            Button2.SetActive(true);
            Button.SetActive(false);
            break;

        case CONTROLLER_STATE.FOUND_CONTROLLER:
            TroubleShootScreen.SetActive(false);
            PairRequest.SetActive(false);
            LoadingCircle.SetActive(true);
            Blinking = false;
            Button2.SetActive(false);
            Button1.SetActive(false);
            Button.SetActive(false);
            InstructionsText.text = "Connecting.. \n\nController Found!";
            break;

        case CONTROLLER_STATE.RECONNECTING:
            TroubleShootScreen.SetActive(false);
            PairRequest.SetActive(false);
            LoadingCircle.SetActive(true);
            StartCoroutine(BlinkLED());
            Button2.SetActive(true);
            Button.SetActive(false);
            InstructionsText.text = "Connecting.. \n\nPlease Ensure The Blue Light Is Blinking On The Connector \n\nPlease Press The Controller Button Once Again";
            break;

        case CONTROLLER_STATE.TROUBLESHOOT:
            TroubleShootScreen.SetActive(true);
            PairRequest.SetActive(false);
            LoadingCircle.SetActive(false);
            InstructionsText.text = "";
            StartCoroutine(TroubleShootBlink());
            Blinking = false;
            Button2.SetActive(true);
            Button1.SetActive(true);
            Button.SetActive(false);
            break;

        case CONTROLLER_STATE.BLE_INACTIVE:
            Blinking = false;
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                InstructionsText.text = "Please ensure Bluetooth is enabled in the Control Center \n\nPlease Press The Controller Button Once Again";
            }
            else if (Application.platform == RuntimePlatform.Android)
            {
                InstructionsText.text = "Please ensure Bluetooth is enabled \n\nPress Connect Once Again";
            }
            else
            {
                InstructionsText.text = "Please ensure Bluetooth is enabled \n\nPress Connect Once Again";
            }

            if (Application.platform != RuntimePlatform.IPhonePlayer)
            {
                Button.SetActive(true);
                ButtonText.text = "Connect";
            }

            PairRequest.SetActive(false);
            Button2.SetActive(true);
            Button1.SetActive(false);
            LoadingCircle.SetActive(false);
            break;

        case CONTROLLER_STATE.PAIR_REQUEST:
            TroubleShootScreen.SetActive(false);
            PairRequest.SetActive(true);
            LoadingCircle.SetActive(true);
            StartCoroutine(BlinkLED());
            Button2.SetActive(true);
            Button.SetActive(false);
            InstructionsText.text = "";
            break;

        case CONTROLLER_STATE.SUBSCRIBED:
            Controller.sprite = Controller_HL;
            Blinking          = false;
            TSBlinking        = false;
            TroubleShootScreen.SetActive(false);
            PairRequest.SetActive(false);
            LoadingCircle.SetActive(false);
            Button2.SetActive(false);
            Button1.SetActive(false);
            InstructionsText.text = "Controller Connected! \n\nPress Ready To Begin";
            ButtonText.text       = "Ready";
            Button.SetActive(true);
            break;
        }
    }