Selected Dialogue not drawn when opening new Editor Window

Is there a known fix for the issue where the currently selected Dialogue asset isn’t drawn when double-clicking the asset and opening a new window (i.e. no window existed prior)?

It seems that the Selection.selectionChanged event is not sent (or received?) if the window is not already open, so the selection change information is lost when double-clicking a Dialogue asset. You have to click elsewhere to deselect the asset and then click the asset again to fire the event and see the correct ScriptableObject data drawn in the Dialogue Editor window.

I have reproduced this issue in the official github repository on today’s master branch, and this hasn’t been addressed. Does anyone know of a fix?

It’s actually a fairly simple fix:
Add this method (leave the existing ShowEditorWindow() in place, or you won’t have the menu item!

public static void ShowEditorWindow(Dialogue candidate = null)
        {
            DialogueEditor window = GetWindow(typeof(DialogueEditor), false, "Dialogue Editor") as DialogueEditor;
            if (candidate)
            {
                window.SelectionChanged();
            }
        }

Then in OnOpenAsset, add the dialogue as a parameter to ShowEditorWindow… here’s how mine looks:

        [OnOpenAsset(1)]
        public static bool OnOpenAsset(int instanceID, int line)
        {
            var candidate = EditorUtility.InstanceIDToObject(instanceID) as Dialogue;
            if (candidate!=null)
            {
                ShowEditorWindow(candidate);
                
                return true;
            }
            return false;
        }
3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms