Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Jean-Marc Primeau
    @jmprimeau
    Bonus question: Shouldn't the result of SelectMany be Disposable in any case as there seems to be a buried subscription in there?
    Martin Gonzalez
    @MartinGonzalez
    Question, is there a way to use Wait() in MainThread?
    Mirko Jugurdzija
    @biotech77
    hi guys, i am trying to upgrade project to unity 2020 and it fails with unirx, what version to use and what to do to make errors disappear? thanks!
    Szymon Gatner
    @slimshader
    @biotech77 I am using UniRx in 2020.2 beta with no problems
    Bastien Guyl
    @bguyl
    Hi there :wave:
    I was using MainThreadDispatcher.Post with an older version, I updated UniRx and now I see there is a n additionnal state argument. Is it required ?
    What it's purpose ?
    chadobado
    @chadobado
    Hey quick question - can anyone comment on the performance of ReactiveProperty and UniRX generally? I'm looking at using UniRX to handle networked streams of blendshape data (collection of 53 structs for each blendshape with int index and float coefficient). With 8 connected clients (each streaming their own blendshapes multiple times/second) it's a lot of data to push. Just want to make sure UniRX is suitable for this requirement. Thanks in advance
    Andrei Müller (Andy Miira)
    @andreiagmu
    Hi! Is this a support community for UniTask (v2) also? I started using UniTask on my Unity project (without UniRx), and I have a question about it
    I want to use the await UniTaskAsyncEnumerable.EveryUpdate().ForEachAsync UniTask notation for Update loop
    And I wanted to know what would be the way to convert the following code to the UniTask notation (how to use multiple loops from different PlayerLoopTimings)
    private void Update()
    {
        ReadInput();
    }
    private void FixedUpdate()
    {
        CharacterUpdate();
    }
    Andrei Müller (Andy Miira)
    @andreiagmu

    I tried doing like this

    private async UniTaskVoid Start()
    {
        var cancellationToken = this.GetCancellationTokenOnDestroy();
    
        await UniTaskAsyncEnumerable.EveryUpdate().ForEachAsync(_ =>
        {
            ReadInput();
    
        }, cancellationToken);
    
        await UniTaskAsyncEnumerable.EveryUpdate(PlayerLoopTiming.FixedUpdate).ForEachAsync(_ =>
        {
            CharacterUpdate();
    
        }, cancellationToken);
    }

    But then, the second await UniTaskAsyncEnumerable.EveryUpdate(PlayerLoopTiming.FixedUpdate) never gets called

    In this case, ReadInput() and CharacterUpdate() are declared as void methods

    Andrei Müller (Andy Miira)
    @andreiagmu
    Alright, I think await UniTask.WhenAll() it's just what I was looking for (to do concurrent task processing)
    private async UniTaskVoid Start()
    {
        var cancellationToken = this.GetCancellationTokenOnDestroy();
    
        var updateTask = UniTaskAsyncEnumerable.EveryUpdate().ForEachAsync(_ =>
        {
            ReadInput();
    
        }, cancellationToken);
    
        var fixedUpdateTask = UniTaskAsyncEnumerable.EveryUpdate(PlayerLoopTiming.FixedUpdate).ForEachAsync(_ =>
        {
            CharacterUpdate();
    
        }, cancellationToken);
    
        await UniTask.WhenAll(updateTask, fixedUpdateTask);
    }
    Alexander Wieser
    @crystalbyte
    Is there a way to await inside the create method?`
       private IObservable<T> Request<T>(string route, string method, object body, HttpOptions options) {
    
                return Observable.Create<T>(observer => { // async missing
                    //  Set default values
                    var request = new UnityWebRequest(route, method);
                    foreach (var header in options.Headers) {
                        request.SetRequestHeader(header.Key, header.Value);
                    }
    
                    foreach (var interceptor in interceptors) {
                        await interceptor.InterceptAsync(request);
                    }
    
                    var response = await request.SendWebRequest().AsObservable();
    Per Hornshøj-Schierbeck
    @Hojou
    I just picked this library up and it doesn't seem to work for my unity 2020 project - i also see the last update to the library is over a year ago - was support stopped?
    I get this error when i try to use a ReactiveProperty:
    error CS0246: The type or namespace name 'ReactiveProperty<>' could not be found (are you missing a using directive or an assembly reference?)
    I'm on Unity 2020.1.17f1
    I have these using statements:
    using System.Collections.Generic;
    using System.Linq;
    using UnityEngine;
    Artur Dębkowski
    @ekhart
    try to add using UniRx; to the script
    kgc00
    @kgc00

    Hi guys,

    new to unirx, sorry if this has been asked- Is there some preferred way to fire off an event or method at under specific conditions? For example

    // hp = reactiveproperty<float>
    if (hp <= 0) execute()

    I'm currently messing around with ReactiveProperties and the MessageBroker to try and achieve this but am not sure if this is the correct aproach

                hp.Select(x => x <= 0).Subscribe(x => {
                    if (x) {
                        Debug.Log("Fire!");
                        MessageBroker.Default.Publish(new Empty());
                        hp.Dispose();
                    }
                }).AddTo(this);

    Does this seem like an okay way to achieve this functionality?

    kgc00
    @kgc00

    ended up here:

    gameObject.UpdateAsObservable().SampleFrame(30).Where(_ => hp <= 0).Distinct().Subscribe(_ => {
                    Debug.Log("Fire!");
                    MessageBroker.Default.Publish(new Empty());
                }).AddTo(this);

    any way to make it so everytime it goes from > 0 to <= 0 it fires?

    kgc00
    @kgc00
    so like:
    100 => 0
    fires once
    0 => 20
    20 => 0
    fires once
    etc
    Jonathan Bro
    @Nomy1
    If you give it a buffer for the previous value then you can compare it with the next value and determine if it's going from positive to negative
    kgc00
    @kgc00
    Thanks! I'll try it out
    kgc00
    @kgc00
    Turns out the pairwise operator was a bit simpler for that usecase so i went with that instead =)
    Jonathan Bro
    @Nomy1
    What's pairwise? A tuple?
    kgc00
    @kgc00
    exactly, it combines the last 2 events in the stream so you can do something like:
    x.OnValueChangedAsObservable()
                    .Where(_ => hp <= 0)
                    .Pairwise()
                    .Where(x => x.Current && !x.Previous)
                    .Subscribe(_ => HandleEvent());
    vbandi
    @vbandi
    Unfortunately, it seems like UniRX has been abandoned. Does anyone know if there's a public/community fork that's being kept up-to-date?
    sparkdsd
    @sparkdsd

    Hi guys!

    var a = new ReactiveProperty<bool>();
    _button.OnClickAsObservable().Subscribe(_ => a.Value = !a.Value); 
    
    a.SelectMany(v => v ? Observable.EveryUpdate().Select(_ => true) : Observable.Return(false)).Subscribe(v => Debug.Log(v));

    I only want Debug.Log work if a.Value==true and when a.Value==false nothing should happen
    But with this code if I switch a.Value = false - Console once print false and then continuously true ( obviously from EveryUpdate )

    Gwendal Broudin
    @GwendalBroudin
    Hi @neuecc thanks for these amazing library, I would love to use these in a long term industrial project. Unfortunately, as @vbandi said, there not a lot of activity those days, is the project still maintained?
    Kevin Streicher
    @NoxMortem
    @vbandi, @GwendalBroudin as @neuecc just merged in code on the 17.4 I wonder what makes you thinkt he project is dead? He is just not extremly active here on gitter as he also maintains a lot of other projects. What feature are you missing? Btw you can check https://github.com/neuecc/UniRx/pulse to see how active it is.
    However, obviously there are tons of issues that should be resolved :)
    vbandi
    @vbandi
    @NoxMortem We are in 20201 - that 17.4 merge hasn't just happened, it was a year ago, in 2020 :) And the last Release is dated almost 2 years ago, in July 2019. There are 38 open PRs, some as recent as last month some like yours from last year, without any merging or comment from the project owner.
    Kevin Streicher
    @NoxMortem
    @vbandi time flies... what a year
    Jonathan Bro
    @Nomy1
    I do hope UniTask is kept up to date at least. I use it a LOT
    Valeri Strucovski
    @vstrucovski_twitter
    image.png
    hello guys, I have question about unitask
    is it possible to write this code shorter, part about Unitask.Action
    Jonathan Bro
    @Nomy1
    Do you need Unitask action? Why not just remove it and type async directly before the _
    Valeri Strucovski
    @vstrucovski_twitter
    @Nomy1 not actually, it's my try to fight with realtime error "OperationCanceledException: The operation was canceled.", which appears with plain 'async _' code
    Szymon Gatner
    @slimshader
    hey everyone! is it also ok to ask questions about MagicOnion here?
    Michael Greenwald
    @mikey555
    From my experiments, I'm finding that Aggregate only fires OnNext when it observes an OnComplete. Is this always the case, or can I somehow make Aggregate fire OnNext when it receives an OnNext?
    Michael Greenwald
    @mikey555
    Never mind, I see this is how Aggregate works. I didn't realize it was also called Reduce in other Rx versions.
    Artur Dębkowski
    @ekhart
    Aggregate is part of older LINQ in fact
    Andy
    @uhbgvfre
    can I use UniRx to traverse bool[3] to find first true, if no result {return custom default value}
    Artur Dębkowski
    @ekhart
    actually, you don't need UniRx - just LINQ
    bools.FirstOrDefault(_ => _ is true)
    Andy
    @uhbgvfre
    Thanks @ekhart
    How can I fix my code err, m_CsBtnStates is bool[6], I want observable result(IObservable<bool>) transfer to bool array
    m_CsBtnStates = signals.ToObservable().Select(x => !x.State);
    1 reply
    Andy
    @uhbgvfre
    and can i use any simple way to refactor this scope
    for (int i = 0; i < m_Signals.Length; i++)
    {
          m_Signals[i].HubPort = i;
          m_Signals[i].IsHubPortDevice = true;
          m_Signals[i].Open(1000);
    }
    EbiPenMan
    @EbiPenMan
    Hi, Is there a complete project that uses UniRX? Which can be examined as an example?
    Artur Dębkowski
    @ekhart
    This message was deleted
    Andy
    @uhbgvfre
    How to instead IObservable<bool> to bool
    anyBtnInteractStream.Throttle(TimeSpan.FromSeconds(3f)).Repeat()
            .Where(_=>playerStateStream.LastOrDefault(x=>x).OfType<bool>())
            .Subscribe(_ => onPlayerInButNoOperateForAWhile.Invoke());
    mruce
    @mruce
    Noob here - hi!
    Looking for help with fairly trivial (I hope) question:
    I have float property, that when changed, executes some code that requires a texture; texture itself is initialized afer a while - so float change might occur when texture is null.
    How can I RX it to make sure float change would trigger the code only it texture is already set? Also - if texture is initialized after float change, it should execute the code as well.
    Jean-Marc Primeau
    @jmprimeau

    @mruce maybe consider something like this:

    var p = new ReactiveProperty<float>();
    var t = this.ObserveEveryValueChanged(_ => GetComponent<Texture>()).Where(_ => _ != null);
    p.CombineLatest(t, (pp,tt) => { /*do stuff here and be certain that the texture (or whatever property is not null) */ }).Subscribe().AddTo(this);

    Not sure where the texture is, but essentially, you make it into a reactive value also and make sure it isn't null, then you do stuff to it only in a combine latest with the float.