Skip to content

ItemPreview - Full Property Inspector option #187

@mgmhunt

Description

@mgmhunt

Inside CollectionItemPropertyDrawer

I've added

            // if (GUI.Button(buttonRect, guiContent))
            // {
            //     showingItemPreview = !showingItemPreview;
            // }
if (GUI.Button(buttonRect, CollectionEditorGUI.EditGUIContent)) OpenOrFocusPropertyEditor(targetItem);}

private static void OpenOrFocusPropertyEditor(Object target)
{
    var propertyEditorType = typeof(Editor).Assembly.GetType("UnityEditor.PropertyEditor");
    var inspectedObjectField = propertyEditorType?.GetField("m_InspectedObject",
        BindingFlags.Instance | BindingFlags.NonPublic);

    if (propertyEditorType != null && inspectedObjectField != null)
        foreach (var w in Resources.FindObjectsOfTypeAll(propertyEditorType).OfType<EditorWindow>())
            if (inspectedObjectField.GetValue(w) as Object == target)
            {
                w.Focus();
                return;
            }

    EditorUtility.OpenPropertyEditor(target);
}

which opens a Property Inspector window instead of the inline dropdown - which for my SOCItems is not useful as I heavily use OdinInspector.
I also needed the inspector window as permanent properties editor so as the Go To button is not useful either as it draws every item in the collection all the time etc

I thought perhaps adding an attribute option for the List for the detail button might be a useful addition to the SOC package? and or a global override in the preferences?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions