Beispiel #1
0
    void Awake()
    {
        _controller = FindObjectOfType <UiController>();

        _speedSlider = transform.Find("Speed/Slider").GetComponent <Slider>();
        _speedSlider.onValueChanged.AddListener(value => HandyConnection.SetSpeedPercent((int)(value * 100f)));
        _lengthSlider = transform.Find("StrokeLength/Slider").GetComponent <Slider>();
        _lengthSlider.onValueChanged.AddListener(value => HandyConnection.SetStrokePercent((int)(value * 100f)));
        transform.Find("BackButton").GetComponent <Button>().onClick.AddListener(() => _controller.SetPanel("ConnectionUI"));
        transform.Find("ScriptButton").GetComponent <Button>().onClick.AddListener(() => {
            _controller.SetPanel("ScriptUI");
        });

        _playerInput = GetComponent <PlayerInput>();
        _playerInput.onActionTriggered += HandleActionTriggered;
    }
Beispiel #2
0
    private void Connect(string connectionKey)
    {
        _connectButton.interactable      = false;
        _connectionKeyInput.interactable = false;

        HandyConnection.ConnectionKey = connectionKey;
        HandyConnection.GetVersion(data =>
        {
            _handyStatusText.text        = "Handy Status: Connected";
            _continueButton.interactable = true;
            _testSlider.interactable     = true;
            PlayerPrefs.SetString("ConnectionKey", connectionKey);

            _connectButton.interactable      = true;
            _connectionKeyInput.interactable = true;
        }, error =>
        {
            _handyStatusText.text            = "Handy Status: Failed - " + error;
            _connectButton.interactable      = true;
            _connectionKeyInput.interactable = true;
        });
    }
Beispiel #3
0
    void Awake()
    {
        _controller = FindObjectOfType <UiController>();

        _connectionKeyInput = transform.Find("ConnectionKeyInput/InputField").GetComponent <InputField>();
        _connectButton      = transform.Find("ConnectButton").GetComponent <Button>();
        _connectButton.onClick.AddListener(() => Connect(_connectionKeyInput.text));

        _handyStatusText = transform.Find("HandyStatusText").GetComponent <Text>();
        _gamepadText     = transform.Find("GamepadStatusText").GetComponent <Text>();
        _responseText    = transform.Find("ResponseText").GetComponent <Text>();
        _continueButton  = transform.Find("ContinueButton").GetComponent <Button>();
        _continueButton.onClick.AddListener(() => _controller.SetPanel("ControlUI"));

        _testSlider = transform.Find("TestSlider").GetComponent <Slider>();
        _testSlider.onValueChanged.AddListener(value => HandyConnection.SetSpeedPercent((int)(value * 100f)));

        if (PlayerPrefs.HasKey("ConnectionKey"))
        {
            _connectionKeyInput.text = PlayerPrefs.GetString("ConnectionKey");
            Connect(_connectionKeyInput.text);
        }
    }