Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        var stringReactiveProperty = new StringReactiveProperty();

        mInputField = transform.Find("InputField").GetComponent <InputField>();
        mText       = transform.Find("Text").GetComponent <Text>();

        //mInputField.BindTextTo(stringReactiveProperty);
        //mText.BindTextTo(stringReactiveProperty);

        //var inputFieldReactiveProperty = new StringReactiveProperty();
        //var textReactiveProperty = new StringReactiveProperty();

        //mInputField.BindTextTo(inputFieldReactiveProperty);
        //mText.BindTextTo(textReactiveProperty);

        //GenericBindings.Bind(inputFieldReactiveProperty, textReactiveProperty);

        //GenericBindings.Bind(() => mInputField.text, x => mInputField.text = x, () => mText.text, inputValue => mText.text = inputValue, BindingsRx.BindingTypes.Default)
        //    .AddTo(mInputField);

        //mInputField.BindTextTo(() => mText.text, value => mText.text = value, filters: new SampleFilter<string>(TimeSpan.FromSeconds(5.0f)));

        //mInputField.OnValueChangedAsObservable().SubscribeToText(mText);

        mInputField.Bind(mText);

        mInputField.OnValueChangedAsObservable().ToReactiveProperty().Subscribe(value => Debug.Log(value));
        //mInputField.BindTextTo(mText);
    }
Пример #2
0
    void Start()
    {
        if (HostButton != null)
        {
            HostButton.onClick.AddListener(() => GameManager.singleton.HostGame());
        }

        if (JoinButton != null)
        {
            JoinButton.onClick.AddListener(() => GameManager.singleton.JoinGame());
        }

        if (PlayerNameInputField != null)
        {
            PlayerNameInputField.BindToPlayerPrefs("PLAYER_NAME", "Unknown");
        }

        if (IpAdressInputField != null)
        {
            IpAdressInputField.BindToPlayerPrefs("IP_ADRESS", "127.0.0.1");
            IpAdressInputField.Bind(s => GameManager.singleton.networkAddress = s);
        }

        if (PortInputField != null)
        {
            PortInputField.BindToPlayerPrefs("PORT", "7777");
            PortInputField.Bind(s => GameManager.singleton.networkPort = int.Parse(s));
        }
    }