TylerTemp / SaintsField

A Unity Inspector extension tool focusing on script fields inspector enhancement
MIT License
148 stars 9 forks source link

ShowIf inside struct not updating until inspector refreshes #29

Closed Gizzmicbob closed 3 months ago

Gizzmicbob commented 3 months ago

I have a monobehaviour with an array of structs. The struct has an enum and a float. The float has a ShowIf attribute for when the enum is a certain value.

When changing the enum, the visibility of the float does not change until I select a different element and then reselect the original (refreshing the inspector).

ShowIf is the only attribute on the float.

TylerTemp commented 3 months ago

Hi, thanks for reporting.

I have trouble re-produce this issue with the following setup:

public class Issue29 : MonoBehaviour
{
    [Serializable]
    public enum Toggle
    {
        Off,
        On,
    }

    [Serializable]
    public struct MyStruct
    {
        public Toggle toggle;
        [ShowIf(nameof(toggle), Toggle.On)] public float value;
    }

    public MyStruct[] myStructs;
}

https://github.com/TylerTemp/SaintsField/assets/6391063/6b18ea3c-d134-4e5d-8b6f-17b4ef96ff78

Unity: 2022.2.0f1

Can you share more so I can reproduce it? Maybe a small piece of example code?

Gizzmicbob commented 3 months ago

Using your provided code, I get the same issue. I'm using 2022.3.20f1. I did previously have NaughtyAttributes installed but it is not longer. Odin is also not installed. https://github.com/TylerTemp/SaintsField/assets/15408031/fc3fb773-26b8-49ef-9232-d525a13cd801

TylerTemp commented 3 months ago

I do manage to reproduce the issue. I both fresh-installed 2022.3.20f1, but on my company's computer (win10) it just works fine, and on my home PC(win11) the bug is there.

The C# reflection function just failed to report a correct value, that's a very weird issue.

Well, this issue seems to require more time to solve (((

TylerTemp commented 3 months ago

Hi, @Gizzmicbob

Please check if it has been fix in 3.0.10

TylerTemp commented 3 months ago

This issue is closed as fixed. If you still have this issue, please comment below and I'll open it.

Gizzmicbob commented 3 months ago

Sorry, forgot to respond. From a brief look, it does appear to have resolved the issue. Thanks