Search Unity

Items being drawn twice, one from Selection.Internal, another from RedrawFromNative

Discussion in 'UI Toolkit' started by MostHated, May 31, 2021.

  1. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    I can't quite figure out how to get rid of this issue. My custom inspectors all get items within a foldout drawn twice as seen below.

    In the logs, I am seeing double entries with the initiator being different for each call.

    The first one being:
    Code (CSharp):
    1. InspectorWindow.RedrawFromNative() at /home/bokken/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:144
    and the second:

    Code (CSharp):
    1. Selection.Internal_CallSelectionChanged() at /home/bokken/buildslave/unity/build/Editor/Mono/Selection.cs:22
    I could not find much info on this, some said you can try restoring default layout in the editor, which I tried, but didn't seem to do anything.

    I don't seem to have this issue in 2019.x, but as soon as I opened the same thing within 2020+ it starts happening.

    Any recommendations?


     
  2. Crouching-Tuna

    Crouching-Tuna

    Joined:
    Apr 4, 2014
    Posts:
    82
    Seeing the same thing, and yes i had no issue from 2019.4, then recently upgraded to 2020.3 and UITK preview14

    My issue is not only 1 tho but a few, including these
    https://forum.unity.com/threads/reg...a-breaking-change-in-a-recent-update.1036942/
    https://forum.unity.com/threads/ins...-causes-failed-to-load-window-layout.1061810/
    Which i've fixed/understood and then applied the workaround/gotcha points

    The difference with OP is i'm getting the double call even when returning early in my CreateInspectorGUI. So, not limited to dropdown

    Edit: not to mention the crash almost whenever i recompile and have the custom inspector inspected
     
  3. martinpa_unity

    martinpa_unity

    Unity Technologies

    Joined:
    Oct 18, 2017
    Posts:
    479
  4. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    I know it *says* it's fixed. I am still having this issue, all the way up to 2022.2b90.

     
  5. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    still in 2022.3.9 from:

    UnityEditor.InspectorWindow:RedrawFromNative () (at /home/bokken/build/output/unity/unity/Editor/Mono/Inspector/InspectorWindow.cs:195)

    and

    UnityEditor.Selection:Internal_CallSelectionChanged () (at /home/bokken/build/output/unity/unity/Editor/Mono/Selection.cs:37)

    Edit: I have found a reliable way to *stop* it for a single selection.

    Select my GameObject in the hierarchy.
    Hit the lock icon
    Deselect the GameObject.
    Unlock the lock icon.
    Select the GameObject again. -> This time it only selects it once using:

    UnityEditor.InspectorWindow:RedrawFromNative () (at /home/bokken/build/output/unity/unity/Editor/Mono/Inspector/InspectorWindow.cs:195)

    No Internal_CallSelectionChanged is called, and all of my events and queries work. Otherwise all of my events and queries report good on the initial selection, but when it deselects and selects it again with Internal_CallSelectionChanged, for some reason not all of my VisualElement queries work, thus making my events not work.

    Seen below, it is pretty much the same behavior as my original post, but a completely separate project, different code, different PC even, from the original post. Same end result.

    The 'listView' line is the result of a VisualElement query. You can see on the 3rd log entry, it finds it, but after Internal_CallSelectionChanged is called, the second time around, the query fails.

     
    Last edited: Sep 10, 2023
  6. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Obviously not idea, but using EditorApplication.delayCall (as opposed to trying to use a GeometryChanged event) in the event that my list is not found via query, to check again, seems to be able to find it eventually. I really wish I knew why it keeps creating the editor, destroying it and reselecting and creating it again, though (or a better-suited workaround to stop it from deselecting it?)
     
    Last edited: Sep 13, 2023