Cysharp / R3

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

[Unity 6] Can not Handle Error When Using [Observablelist].ObserveAdd().Subscribe(function) #236

Closed franktmy closed 3 months ago

franktmy commented 3 months ago

When work with ObservableCollections.R3 in Unity 6.

Code is:

Observablelist.ObserveAdd() .Subscribe(x => { throw new SystemException("log error test"); });

There isn't any error log on the unity console,So how can I handle error in this case?

franktmy commented 3 months ago

Fixed:There isn't any error log on unity console when I add element to the list .

neuecc commented 3 months ago

I can't reproduce it.

image

using ObservableCollections;
using R3;
using System;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    ObservableList<int> Observablelist = new ObservableList<int>();

    void Start()
    {
        Observablelist.ObserveAdd()
            .Subscribe(x =>
            {
                throw new SystemException("log error test");
            });

        Observablelist.Add(1);
    }
}
franktmy commented 3 months ago

I can't reproduce it.

image

using ObservableCollections;
using R3;
using System;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    ObservableList<int> Observablelist = new ObservableList<int>();

    void Start()
    {
        Observablelist.ObserveAdd()
            .Subscribe(x =>
            {
                throw new SystemException("log error test");
            });

        Observablelist.Add(1);
    }
}

I‘m sorry I don’t mention the actually vision,I'm in 6000.0.5f1 https://unity.com/cn/releases/editor/whats-new/6000.0.5


using ObservableCollections;
using R3;
using System;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour { ObservableList Observablelist = new ObservableList();

void Start()
{
    Debug.Log("I'm Start!");
    Observablelist.ObserveAdd()
        .Subscribe(x =>
        {
            throw new SystemException("log error test");
        });

    Observablelist.Add(1);
    Debug.Log("I'm End!");
}

}


![屏幕截图 2024-07-23 092651](https://github.com/user-attachments/assets/2f803701-b040-4cbc-b058-460c6916a188)

![屏幕截图 2024-07-23 092332](https://github.com/user-attachments/assets/4a23c99a-1577-4f99-9e0e-23f44f10087e)
neuecc commented 3 months ago

The latest seems to be 6000.0.11f1, so could you try 6000.0.11f1? Also, did you include R3 from PackageManager with the additional steps? If you don't include it, the unhandled exception will not be notified to the Unity Console.

franktmy commented 3 months ago

You are right,the reason is I missed step 2: Install the R3.Unity package by referencing the git URL. Thank you for your patience.