Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Pierrick Bignet
    @RDeluxe
    Note that I'm using this in a different contexte (not a click) it may also be the cause of the error
    (it works for the first call, the sound is played correctly, but not for the subsequent calls)
    Ok, same thing with a button
        private async Task PlaySound() {
            Debug.Log("Playing sound  !");
            audioSource.PlayOneShot(GameManager.Instance.GameConfig.FreezeSound);
            await UniTask.Delay(TimeSpan.FromSeconds(3));
            Debug.Log("Played sound !");
        }
    The Task for reference
    What's weird is that, if I click every 4 seconds it will play the sound just fine
    But if I click fast and "pile up" several tasks, then the 1st will play correctly
    But the second will crash with the UnityException: PlayOneShotHelper can only be called from the main thread exception
    Pierrick Bignet
    @RDeluxe
    Btw your code can be simplified I think
            GetComponent<Button>()
                .OnClickAsObservable()
                .Select(_ => { return Observable.Defer(() => LongRunning().ToObservable()); })
                .Concat()
                .Subscribe(x => { Debug.Log(x); });
    This has the same behaviour
    Pierrick Bignet
    @RDeluxe
    Ok, it works perfectly well in another project so I must be doing something awry
    Alright got it
    A call to UniTask.Delay before calling any thread linked method is necessary
    So, this does not work :
       private async Task PlaySound() {
            Debug.Log("Playing sound  !");
            audioSource.PlayOneShot(GameManager.Instance.GameConfig.FreezeSound);
            await UniTask.Delay(TimeSpan.FromSeconds(3));
            Debug.Log("Played sound !");
        }
    But this does
       private async Task PlaySound() {
            Debug.Log("Playing sound  !");
            await UniTask.Delay(TimeSpan.FromSeconds(3));
            audioSource.PlayOneShot(GameManager.Instance.GameConfig.FreezeSound);
            Debug.Log("Played sound !");
        }
    UniTask forces to come back to the main thread
    Gil
    @sendtogil
    @RDeluxe Glad you figured that out!
    besttof
    @besttof
    LP
    @grofit
    Hello
    Sorry not on computer much atm
    Oh yes I saw him post some issue updates, hope it's all sorted now, ecsrx is a pain to maintain due to the rx faffery
    LP
    @grofit
    Hopefully the other watchers can confirm it all works on other platforms (so it has platform parity with Unirx) then we can hopefully just slice the unity stuff from Unirx and bundle that.
    LP
    @grofit
    Also this sort approach can pave the way for other frameworks like godot, monogame, xenko etc where they want to extend system.reactive and add easy to use helpers etc
    besttof
    @besttof
    Hah, the ping was more because I noticed you had a github repo trying with the same goal, so probably in your interest.
    Having the "real" rx library working in Unity (with maybe just a unity scheduler) would be awesome.
    Jesse Vander Does
    @FreakTheMighty
    Hey UniRxrs, I'm looking forward to HoloLens 2 development. Is there any reason to think UniRx won't run on ARM 64?
    Mirko Jugurdzija
    @biotech77
    hi guys...can somebody give me example how to use AsyncMessageBroker so it returns some value when something is done or processed
    AsyncMessageBroker.Default
                .PublishAsync(new BrokerItem { Value = 3000 })
                .Subscribe(_ => 
                {
                    // i need some value
                    Debug.Log("all subscribers done");
                });
    AsyncMessageBroker.Default
                .Subscribe<BrokerItem>(x => 
                {
                    return Observable
                        .Timer(TimeSpan.FromSeconds(1))
                        .ForEachAsync(_ =>
                        {
                            // how to return some value from here?
                        });
                });
    Gil
    @sendtogil
    @biotech77
     AsyncMessageBroker Broker = new AsyncMessageBroker();
            Broker.Subscribe<Item>(x =>
            {
                //do stuff when message received
                Debug.Log($"{x.id}: received");
                return Observable.ReturnUnit()
                    .DelayFrame(100)
                    .DoOnCompleted(() => Debug.Log($"{x.id} processed"));
            });
            Broker.PublishAsync(new Item {id = 1, message = "test"}).Subscribe(_=>
            {
                //do stuff after message processed
                Debug.Log("sent 1");
            });
            Broker.PublishAsync(new Item {id = 2, message = "test2"}).Subscribe(_=>Debug.Log("sent 2"));
            Broker.PublishAsync(new Item {id = 3, message = "test3"}).Subscribe(_=>Debug.Log("sent 3"));
            Broker.PublishAsync(new Item {id = 4, message = "test4"}).Subscribe(_=>Debug.Log("sent 4"));
    if you wanna get the value out, I think you can use ReactiveProperty<T> or update a variable inside of subscribe block
    Jonathan Bro
    @Nomy1
    Is there a way to make a streaming value read only from outside a class, and at the same time expose the last value output from it?
    Martin Gonzalez
    @MartinGonzalez
    Hi people! I've a question about something strange happening. I have two projects using the same dependency (another module using Tuple) I have the using System & using UniRx libraries and in one project everything works fine and in another it says ambiguous reference. Is there some Unity config or something that I have the set up to avoid this?
    Jonathan Bro
    @Nomy1

    What is the recommended way to wait for two UniTasks and get a value from only one? Only one of the UniTasks returns a variable.

    var task1 = Task();
    var task2 = Task();

    var x = UniTask.WhenAll(task1, task2);

    doesn’t work

    Jonathan Bro
    @Nomy1
    I mean, it works of course I'd you return Unit, but I don't understand why I'd want to use Unit.
    Martin Gonzalez
    @MartinGonzalez
    Hi! Is there any reason why removing Unity.Asyn asmdef is just a minor and not a major? I mean, from 7.0.0 to 7.1.0 there Unity.Async is removed and that produce errors
    Kevin Streicher
    @NoxMortem
    @MartinGonzalez Not sure UniRx follows SemVer
    pedrobacchini
    @pedrobacchini
    How do I translate this to unirx, I tried this but to no avail
    Screen Shot 2019-10-06 at 2.52.03 PM.png
    RaeTheLynn
    @RaeTheLynn
    I would make the myHeroClass.AnimatorController a ReactiveProperty and then you can subscribe directly to it. Do a null check in the subscription and you should be good.
    Or do you just want to do the check at that point in time? What exactly are you trying to do?
    nanikore
    @erectsnake_twitter
    Hey, anybody here?
    I was wondering if anybody knows a stand alone ReactiveProperty library for unity, similar to the one in UniRx.
    Or if there is a way to use ReactiveProperties without downloading the entire UniRx library.
    I love UniRx, but right now I don't want to add to my project anything I don't immediately need
    MinYufeng
    @ResidualSoils
    Maybe you can write your own ReactiveProperties.
    // in UniRx
    public T Value
    {
        get
        {
            return value;
        }
        set
        {
            if (!EqualityComparer.Equals(this.value, value))
            {
                SetValue(value);
                if (isDisposed)
                    return;
    
                RaiseOnNext(ref value);
            }
        }
    }
    RaeTheLynn
    @RaeTheLynn
    @nanikore From what I can see in the source code, ReactiveProperty doesn't have many hooks to the rest of the library. You can likely take ReactiveProperty.cs and IOptimizedObservable.cs and you should be good.