Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Modifying ExposedProperties doesn't trigger EndChangeCheck in custom editor windows

Discussion in 'Visual Effect Graph' started by lorewap3, Sep 11, 2022.

  1. lorewap3

    lorewap3

    Joined:
    Jun 24, 2020
    Posts:
    58
    Greetings!

    I was hesitant to call this a bug as it maybe by design, but for backwards compatibility I think it qualifies.

    The issue is I have a custom editor window. It reads prefabs and displays editors for specific components at specific times. So far this has worked for every other Unity I've needed to use within a custom editor. Except for the VisualEffect component.

    This is the basic mechanism to check for changes within the editor window. It works for ParticleSystem, Transforms, etc, but not for the VisualEffect component.
    Code (CSharp):
    1. EditorGUI.BeginChangeCheck();
    2. visualEffectEditors[index].OnInspectorGUI();
    3. if (EditorGUI.EndChangeCheck())
    I did, however, fix it locally on my end. This is a section of code from Editor/Inspector/VisualEffectEditor.cs source, modified to set GUI.changed = true if modifications were made:

    This is the very end of the OnInspectorGUI function:
    Code (CSharp):
    1. /// 2022-06-05 - Will
    2. /// Added change flag to capture modified parameters
    3. bool changed = false;
    4. if (!m_VisualEffectAsset.hasMultipleDifferentValues)
    5. {
    6.     if (showGeneralCategory)
    7.         InitialEventField(resource);
    8.  
    9.     DrawRendererProperties();
    10.     /// 2022-06-05 - Will Poillion
    11.     /// Modified DrawParameters to return a bool if a parameter was modified.
    12.     changed = DrawParameters(resource);
    13. }
    14. EditorGUI.indentLevel = 0;
    15. if (serializedObject.ApplyModifiedProperties())
    16. {
    17.     var window = EditorWindow.GetWindow<VFXViewWindow>();
    18.     if (window != null)
    19.         window.OnVisualEffectComponentChanged(targets.Cast<VisualEffect>());
    20. }
    21. /// 2022-06-05 - Will
    22. /// If changed, then set GUI.changed = true to trigger EndChangeCheck
    23. if (changed)
    24.     GUI.changed = true;
    And in order for the DrawParameters to returned whether a parameter has been changed or not, this is added to the top of the DrawParameters function:
    Code (CSharp):
    1. /// Added changed bool
    2. bool changed = false;
    And then at the end set the changed flag if properties were modified:
    Code (CSharp):
    1.                             /// 2022-06-05 - Will
    2.                             /// If any property modified, then set changed flage
    3.                             if (m_SingleSerializedObject.ApplyModifiedProperties())
    4.                             {
    5.                                 changed = true;
    6.                                 GUI.changed = true;
    7.                             }
    8.                         }
    9.                     }
    10.                 }
    11.             }
    12.         }
    13.     }
    14.     GUILayout.Space(1); // Space for the line if the last category is closed.
    15.  
    16.     /// 2022-06-05 - Will
    17.     /// Return changed flag
    18.     return changed;
    19. }

    I was hesitant to call it a bug as I imagine this means of detecting editor changes might be falling out of favor and on the road to being deprecated. However, in the meantime this is the means I'm aware of to detect changes to the exposed properties.

    I'm using the latest 12.1.7 version of VFX graph on Unity 2021.3.9f1. I'm attaching the entire VisualEffectEditor.cs to get the fully customized file.

    Again, let me know if there's a more accepted way of doing this. Or if this is truly a bug, then I'm glad I labeled it as such!

    Thanks!
    Will
     

    Attached Files:

    Last edited: Sep 11, 2022
    OrsonFavrel likes this.
  2. lorewap3

    lorewap3

    Joined:
    Jun 24, 2020
    Posts:
    58
    Bump. Just hoping to get an acknowledgement from Unity that they're actually aware of this issue. Or at minimum that they even consider it an issue.
     
  3. Julien-A

    Julien-A

    Unity Technologies

    Joined:
    Jun 10, 2021
    Posts:
    5
    Hi,
    Thanks for pointing this to our attention and for the proposed fix!
    I created a ticket on our side to not forget about it and keep track of the progress.

    Thanks!
     
    Vita- likes this.
  4. lorewap3

    lorewap3

    Joined:
    Jun 24, 2020
    Posts:
    58
    Thank you Julien for the response!

    I apologize if this is a noob question, but is there a publicly accessible location to watch tickets like that? It's no problem if there isn't, I was just wondering. I imagine that would be a very difficult logistical challenge.

    But aside from that, is there is a way to watch for things like this? Or is the main mechanic simply to watch for newest releases of VisualEffect component and check for fixes at that time? Is there a way to get notifications on updates for specific components? Like, get an email when the VisualEffect component releases a new version?

    This is very low priority and I apologize for the noob questions. I am really just curious how other developers watch or keep track of bugs they've reported. I've honestly never had to do it before.

    Thanks again Julien I appreciate your response!
    Will
     
  5. Julien-A

    Julien-A

    Unity Technologies

    Joined:
    Jun 10, 2021
    Posts:
    5
    Hi,
    Yes, you can track the progress of the logged ticket here.
    Sorry for not posting the link before.
     
    Vita- likes this.