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

IMGUI: Regression: GetComponentInChildren(false, typeof(MudCurvePoint), true)] no longer works #102

Open
laurentopia opened this issue Nov 15, 2024 · 19 comments
Assignees
Labels
bug Something isn't working

Comments

@laurentopia
Copy link

it zeroes out what used to be assigned
image
image
image

@TylerTemp TylerTemp self-assigned this Nov 18, 2024
@TylerTemp TylerTemp added the bug Something isn't working label Nov 18, 2024
@TylerTemp TylerTemp removed the bug Something isn't working label Nov 18, 2024
TylerTemp added a commit that referenced this issue Nov 18, 2024
@TylerTemp TylerTemp removed this from the Building Nothing Out of Something milestone Nov 18, 2024
@TylerTemp
Copy link
Owner

Hi,

I tried to re-produce it in 2022.2.0f1/2019.4.0f1/2021.3.0f1 with 3.4.12, with/without SaintsEditor, under IMGUI & UI Toolkit but can not re-produce.

More information might be needed, e.g.

  1. Your Unity version
  2. Can you ensure your child objects are active
  3. Does it work if you click the plus button?
public class Issue102 : MonoBehaviour
{
    [SerializeField, GetComponentInChildren(false, typeof(MudCurvePoint), true)]
    private List<Transform> mPoints = new List<Transform>();
}

(Example shown IMGUI & UI Toolkit without SaintsEditor so I clicked the plus button here)

Unity_SiK6lorFeP.mp4

@laurentopia
Copy link
Author

Your Unity version: 2020.3.48
Can you ensure your child objects are active: they all are
Does it work if you click the plus button? : no change and console fills with errors
image

@laurentopia
Copy link
Author

by the way, i see the video waits for + to be pressed. previous behavior didn't require that.

@TylerTemp
Copy link
Owner

Your Unity version: 2020.3.48 Can you ensure your child objects are active: they all are Does it work if you click the plus button? : no change and console fills with errors image

Got you. I'm checking on that.

I caught a cold so everything will be slow until I get better though...


by the way, i see the video waits for + to be pressed. previous behavior didn't require that.

This is because I didn't enable SaintsEditor when recording this video

@TylerTemp
Copy link
Owner

Hi,

unfortunately, with the code above, with Unity 2020.3.48f1, with SaintsField 3.4.12, with SaintsEditor enabled, with either UI Toolkit or IMGUI, I'm unable to re-produce this issue:

Unity_OHj2YR7EBt.mp4

According to the error, it indicate that the data is removed, maybe you can check if a OnValidate or similar is removing it? Or an inherence of the class that have some code about it?

In short at this point I can not re-produce it thus Im unable to do anything with it, until a re-producable env is given...

Here is a prefab you can have a try:

Issue102Prefab.zip

@TylerTemp TylerTemp added the question Further information is requested label Nov 19, 2024
@laurentopia
Copy link
Author

It does that .Clear thing which used to be fine with the attribute.
image

@TylerTemp
Copy link
Owner

Can you show the code where Points's setter gets called?

@TylerTemp
Copy link
Owner

It does that .Clear thing which used to be fine with the attribute. image

It's not about regression, but about Unity's undocumented features (or to say, bugs): there are certain actions that will just break the process, and it's just not written in any Unity's document. Usually there is a way to avoid it, but you'll never know that pitfall until you fall...

The only way is to find what is wrong, and deal with it. This happens a loooooot in Inspector's development. Many issues that resolved in this project are because of Unity's undocumented behaviors.

@laurentopia
Copy link
Author

laurentopia commented Nov 21, 2024

Can you show the code where Points's setter gets called?

image

and that init is called only when a new GO is created... big codebase so lemme see if that gets called as some sort of editor init.

nope

and i commented out the clear, same behavior.

so i propose this: send me an a 2 month old version of saintsfield and i'll test it, if it works then at least you can narrow it down to a diff. I'd do it from my git but i excluded the Library/PackageCache, like a dummy

@laurentopia
Copy link
Author

laurentopia commented Nov 21, 2024

I tried your test script and it doesn't work for me. I use 2020.3.48
image

NFjfnGd3P0.mp4

image

image

@laurentopia
Copy link
Author

Maybe this bug is related to the performance drop of the last few updates. Seems like a lot of calls.
this is the hierarchy and each GO has 4 components if you count transform as a component so maybe that explains the high number of fieldhandle getvalue, still it seems to be digging for fields when all that's needed are component.
image
image
image

@laurentopia
Copy link
Author

I reverted to an old version that was sitting in the u6 repo and it works.
image
today.comes.saintsfield.zip

@TylerTemp
Copy link
Owner

Thanks for the details! I think I get some ideas about what this is about.

However, I'm still recovering from a flu so even a temp fix will need a couple of days... sorry for the inconvenience


About downgrade, depending on how you install it, there are some easy way, I'll update to the document later:
  1. UnityPackage: just download a old one from release

  2. git: open Packages/manifest.json and change it to like this:

    {
        "dependencies": {
            "today.comes.saintsfield": "https://github.com/TylerTemp/SaintsField.git#3.3.8",  // change 3.3.8 to the target downgrade version
            // your other dependencies...
        }
    }
  3. openupm:

    {
        "dependencies": {
            "today.comes.saintsfield": "3.3.8",  // change 3.3.8 to the target downgrade version
            // your other dependencies...
        }
    }

Then restart the Unity

@laurentopia
Copy link
Author

No worry, eat loads of chicken soup

@TylerTemp
Copy link
Owner

TylerTemp commented Dec 2, 2024

Hi,

looks like the serialized property get disposed. This situation very rarely happens in IMGUI. (...and often happens in UI Toolkit...) One possible reason is that the data got removed in OnValidate. (OnValidate is not recommended to modify data according to Unity's document, but... we, including me, just do that all the time...)

There are some way to avoid it. I'll push a release later.

It will also change some default behavior of IMGUI which related to the performance impact, and align it partly to the old version's behavior( related to #98 ). Please have a try after releasing

@TylerTemp TylerTemp added bug Something isn't working and removed question Further information is requested labels Dec 2, 2024
@TylerTemp
Copy link
Owner

Hi,

This is supposed to be fixed in 3.6.1, please have a try,

@TylerTemp TylerTemp changed the title Regression: GetComponentInChildren(false, typeof(MudCurvePoint), true)] no longer works IMGUI: Regression: GetComponentInChildren(false, typeof(MudCurvePoint), true)] no longer works Dec 9, 2024
@laurentopia
Copy link
Author

I confirm it does. Well done!

@laurentopia laurentopia reopened this Dec 20, 2024
@laurentopia
Copy link
Author

laurentopia commented Dec 20, 2024

Errata: doesn't work.
repro: zero out list count
should be: repopulate
what happens: errors and no populating
also: when drag and dropping errors in console and no populating
image

image

System.InvalidOperationException: The operation is not possible when moved past all properties (Next returned false) at UnityEditor.SerializedProperty.Verify (UnityEditor.SerializedProperty+VerifyFlags verifyFlags) [0x00068] in <25578071f6e44201aac745680e5c8dfc>:0 at UnityEditor.SerializedProperty.get_propertyType () [0x00001] in <25578071f6e44201aac745680e5c8dfc>:0 at UnityEditor.PropertyHandlerCache.GetPropertyHash (UnityEditor.SerializedProperty property) [0x00032] in <25578071f6e44201aac745680e5c8dfc>:0 at UnityEditor.PropertyHandlerCache.GetHandler (UnityEditor.SerializedProperty property) [0x00001] in <25578071f6e44201aac745680e5c8dfc>:0 at UnityEditor.ScriptAttributeUtility.GetHandler (UnityEditor.SerializedProperty property) [0x0003c] in <25578071f6e44201aac745680e5c8dfc>:0 at UnityEditor.EditorGUI.PropertyFieldInternal (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) [0x00001] in <25578071f6e44201aac745680e5c8dfc>:0 at UnityEditor.EditorGUI.PropertyField (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) [0x00001] in <25578071f6e44201aac745680e5c8dfc>:0 at SaintsField.Editor.Core.SaintsPropertyDrawer.UnityDraw (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Reflection.FieldInfo fieldInfo) [0x00057] in Z:\MC0\Library\PackageCache\today.comes.saintsfield@d1364351da\Editor\Core\SaintsPropertyDrawer.cs:1773 UnityEngine.Debug:LogError (object) SaintsField.Editor.Core.SaintsPropertyDrawer:UnityDraw (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent,System.Reflection.FieldInfo) (at Library/PackageCache/today.comes.saintsfield@d1364351da/Editor/Core/SaintsPropertyDrawer.cs:1777) SaintsField.Editor.Core.SaintsPropertyDrawer:DefaultDrawer (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent,System.Reflection.FieldInfo) (at Library/PackageCache/today.comes.saintsfield@d1364351da/Editor/Core/SaintsPropertyDrawer.cs:1710) SaintsField.Editor.Core.SaintsPropertyDrawer:OnGUI (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent) (at Library/PackageCache/today.comes.saintsfield@d1364351da/Editor/Core/SaintsPropertyDrawer.cs:1396) UnityEditor.PropertyHandler:OnGUI (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent,bool) UnityEditorInternal.ReorderableList/Defaults:DrawElement (UnityEngine.Rect,UnityEditor.SerializedProperty,object,bool,bool,bool,bool) UnityEditorInternal.ReorderableList:DoListElements (UnityEngine.Rect,UnityEngine.Rect) UnityEditorInternal.ReorderableList:DoList (UnityEngine.Rect,UnityEngine.Rect) UnityEditorInternal.ReorderableListWrapper:Draw (UnityEngine.GUIContent,UnityEngine.Rect,UnityEngine.Rect,string,bool) UnityEditor.Editor:OnInspectorGUI () MudBun.MudBrushEditor:OnInspectorGUI () (at Assets/MudBun/Script/Editor/MudBrushEditor.cs:61) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
SerializedProperty m_points.Array.data[0] has disappeared! UnityEditor.SerializedProperty:get_propertyPath () SaintsField.Editor.Core.InsideSaintsFieldScoop:MakeKey (UnityEditor.SerializedProperty) (at Library/PackageCache/today.comes.saintsfield@d1364351da/Editor/Core/InsideSaintsFieldScoop.cs:39) SaintsField.Editor.Core.SaintsPropertyDrawer:UnityDraw (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent,System.Reflection.FieldInfo) (at Library/PackageCache/today.comes.saintsfield@d1364351da/Editor/Core/SaintsPropertyDrawer.cs:1741) SaintsField.Editor.Core.SaintsPropertyDrawer:DefaultDrawer (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent,System.Reflection.FieldInfo) (at Library/PackageCache/today.comes.saintsfield@d1364351da/Editor/Core/SaintsPropertyDrawer.cs:1710) SaintsField.Editor.Core.SaintsPropertyDrawer:OnGUI (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent) (at Library/PackageCache/today.comes.saintsfield@d1364351da/Editor/Core/SaintsPropertyDrawer.cs:1396) UnityEditor.PropertyHandler:OnGUI (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent,bool)

@TylerTemp
Copy link
Owner

Understood. Will check it after this weekend :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants