Ejemplo n.º 1
0
        private async void Start()
        {
            _cancellationToken = this.GetCancellationTokenOnDestroy();
            _flowingTextPool   = new FlowingTextPool(_flowingTextPrefab, _rootCanvas.transform);

            _flowingTextSettings = await ServiceLocator.GetServiceAsync <IFlowingTextSettings>(_cancellationToken);

            _flowingTextSettings.OnFontSizeChange()
            .Subscribe(x => { _fontSize = x; }).AddTo(this);

            var server = await ServiceLocator.GetServiceAsync <IServer <string> >(_cancellationToken);

            try
            {
                _messageReceiver = await server.GetMessageReceiverAsync(_cancellationToken);

                _messageReceiver
                .OnMessage()
                .ObserveOnMainThread()
                .Subscribe(x => { this.FlowMessage(x).Forget(); })
                .AddTo(this);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 2
0
        private async void Start()
        {
            _connectButton.enabled = false;

            var server = await ServiceLocator.GetServiceAsync <IServer <string> >();

            _connectButton.enabled = true;

            _viewModel = new ConnectionSettingUiViewModel(server);

            _connectButton
            .onClick
            .AsObservable()
            .Subscribe(_ => { this.OnClickConnectionButton().Forget(); }).AddTo(this);

            _transparentButton.onClick
            .AsObservable()
            .Subscribe(_ => { this.OnClickTransparentButton(); }).AddTo(this);

            _closeButton.onClick
            .AsObservable()
            .Subscribe(_ => this.Close().Forget())
            .AddTo(this);

            _minimizeButton.onClick
            .AsObservable()
            .Subscribe(_ => this.SwitchWindow().Forget());

            _minimumWindow.OnDoubleClick()
            .Subscribe(_ => this.SwitchWindow().Forget());

            _flowingTextSettings = await ServiceLocator.GetServiceAsync <IFlowingTextSettings>();

            _fontSizeSlider.onValueChanged
            .AsObservable()
            .Subscribe(this.OnFontSizeChange)
            .AddTo(this);

            await UniTask.NextFrame();

            _flowingTextSettings.FontSize = _fontSizeSlider.value;

            _minimumWindow.gameObject.SetActive(false);
        }