TylerTemp / SaintsField

A Unity Inspector extension tool focusing on script fields inspector enhancement
MIT License
148 stars 9 forks source link

Feature Request: Support for `[Searchable]` #24

Closed tim-altitudegames closed 2 months ago

tim-altitudegames commented 3 months ago

Something I'd love to see is support for the [Searchable] attribute for lists/arrays, helps deal with sizeable entities in the inspector

329103583-e1872856-85cf-405d-bbf1-2957bbb9d04e

TylerTemp commented 3 months ago

Unfortunately, this feature requires some heavy work.

For most of the time, you can always use Odin together with SaintsField, as long as you

  1. Do not enable SaintsEditor globally (and not use SaintsEditor related properties)
  2. Do not use some edge cases like Odin's serialization tool for non-serializable object, especially Odin's EditorWindow.

The difficulty of this feature is, Unity does not naturally allow to make a "list/array drawer" with a CustomPropertyDrawer way, but only allows on UnityEditor.Editor way. Which means this feature requires to completely re-write Unity's reorder-able list rendering (like what Odin did). Some other workaround is to hijack the property drawer for first element of array/list and ignore the rest element (like how Editor GUI Table did)

So, in short, I'll only re-consider it again after I finish some other features for this project. Before that I'll leave this issue open for now.

Any suggestion & PR is welcome!

TylerTemp commented 2 months ago

@tim-altitudegames Hi,

Please check version 3.1.1 and ListDrawerSettings document

This issue is closed as implemented. However, this component is quite heavy so is expected to have some bugs. Feel free to report issues if you find any problems.

using SaintsField.Playa;

[Serializable]
public struct MyData
{
    public int myInt;
    public string myString;
    public GameObject myGameObject;
    public string[] myStrings;
}

[ListDrawerSettings(searchable: true, numberOfItemsPerPage: 3)]
public MyData[] myDataArr;

image