Opening a dialogue scriptable from the inspector won't show contents

I’m trying to open the dialogue from the Inspector (because it would be faster than searching for the file in the Project tab) but it just opens the “Dialogue not selected” tab.

I did some debugging, and I noticed that in DialogueEditor script, Selection.activeObject keeps newDialogue at null only when it’s selected from the inspector.

image

Is there a fix round this? I couldn’t find much documentation about it. Thanks in advance.

I don’t think there is a fix for it, but I can have a look around. Clicking it in the inspector would have ‘pinged’ it in the Project tab, so you don’t really have to search for it.

You could also make some sort of property drawer that can draw a button next to the field which will open the window with the selected dialogue. It shouldn’t be too hard. Something like

// This goes in the editors folder with the dialogue editor - provided as-is
// DialoguePropertyDrawer.cs
using UnityEditor;
using UnityEngine;

namespace RPG.Dialogue.Editor
{
    [CustomPropertyDrawer(typeof(Dialogue))]
    public class DialoguePropertyDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                position.width -= 20f;
                EditorGUI.PropertyField(position, property, label);

                position.x = position.width + 20f;
                position.width = 20f;
                if (GUI.Button(position, GUIContent.none, EditorStyles.miniButton))
                {
                    Selection.activeObject = property.objectReferenceValue;
                    DialogueEditor.ShowEditorWindow();
                }
            }
        }
    }
}

It’s just an ‘empty’ button next to the dialogue, and clicking it will open the editor.

image

1 Like

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

Privacy & Terms