Cysharp / R3

The new future of dotnet/reactive and UniRx.
MIT License
2.27k stars 99 forks source link

ChunkFrame not working as it should #252

Closed siberhecy closed 2 months ago

siberhecy commented 2 months ago

I'm trying to move on from UniRx to R3.

In UniRx following code was working perfectly;

_isOutfitDataDirty
.BatchFrame() // Delay notifications until the end of the frame
.Subscribe(_ => {
    Debug.Log("Outfit data dirty is changed.");
    if(_isOutfitDataDirty.Value)
        RepaintOutfits();
});

but then I switched to R3 I replaced BatchFrame with ChunkFrame as the document said, it started to didn't work anymore, there was no Debug.Log in console.

neuecc commented 2 months ago

UniRx's ChunkFrame() is EndOfFrame, but R3's ChunkFrame() has Update as the default timing. You can use .ChunkFrame(0, UnityFrameProvider.PostLateUpdate) or .ChunkFrame(0, UnityFrameProvider.TimeUpdate).

By the way, if you just want to wait at the end of the frame, it seems more efficient to use a different method rather than ChunkFrame.

siberhecy commented 2 months ago

Hello! .ChunkFrame(0, UnityFrameProvider.PostLateUpdate) worked well thanks! The reason I use ChunkFrame (previously BatchFrame) there is multiple objects can change the value of "_isOutfitDataDirty" property that triggers heavy re-build function. So this is why I waited end of the frame for heavy function.