Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SerializedReactiveProperties Odin Inspector support #257

Open
devcube9 opened this issue Sep 5, 2024 · 7 comments
Open

SerializedReactiveProperties Odin Inspector support #257

devcube9 opened this issue Sep 5, 2024 · 7 comments

Comments

@devcube9
Copy link

devcube9 commented Sep 5, 2024

Thank you for developing this amazing framework.

Currently, when using SerializedReactiveProperties with Odin inspector, there is an error when changing their values in the inspector.

? fieldInfo.GetValue(attachedComponent)

Similar issues was found in UniRx here:

neuecc/UniRx#531
neuecc/UniRx#452

Unlike the issues in UniRx, fieldInfo is null in R3

@neuecc
Copy link
Member

neuecc commented Sep 5, 2024

thanks, I'll check it.

@neuecc
Copy link
Member

neuecc commented Sep 27, 2024

I've tested at Unity 6000.0.20f1 and Odin 3.3.1.8, maybe it works.
Can you check it for me?
Also, I would be grateful if you could provide the MonoBehaviour code for the case where it doesn't work.

@neuecc neuecc closed this as completed Oct 7, 2024
@devcube9
Copy link
Author

using R3;
using Sirenix.OdinInspector;
using UnityEngine;

class Test {
    [SerializeField] private SerializableReactiveProperty<int> reactiveProperty;
}

public class SerializableReactivePropertyOdinError : SerializedMonoBehaviour {

    [SerializeField] private Test test;

}

I tested again and found that it only throws an error when a SerializableReactiveProperty is nested inside a class

@neuecc
Copy link
Member

neuecc commented Oct 22, 2024

thanks, I'll check it again.

@neuecc neuecc reopened this Oct 22, 2024
@alijaya
Copy link

alijaya commented Jan 15, 2025

any update on this? It's happen when ReactiveProperty is serialized by Odin Serialization. So it will happen too when SerializableReactiveProperty<int> inside the MonoBehaviour and marked with [OdinSerialize, NonSerialized]

@alijaya
Copy link

alijaya commented Jan 15, 2025

Hi, I've tested this, and somehow fieldInfo is not always non-null, so there's a case where it's null, not sure what.
I've solved this by changing this lines

var targetProp = (paths.Length == 1)
                    ? fieldInfo.GetValue(attachedComponent)
                    : GetValueRecursive(attachedComponent, 0, paths);

into

var targetProp = GetValueRecursive(attachedComponent, 0, paths);

So don't need to check if paths.Length is 1, and just skip the fieldInfo altogether and use GetValueRecursive

And it's working now.

@neuecc
Copy link
Member

neuecc commented Jan 23, 2025

I see, retrieving fresh FieldInfo from Type.
Since my Odin trial has expired, I can't test it, but that approach seems viable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants