TylerTemp / SaintsField

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

Any way to colour the name of a list? #18

Closed TheEmbracedOne closed 4 months ago

TheEmbracedOne commented 4 months ago

First and foremost, thank you for this amazing tool! I'm currently using it along NaughtyAttributes. I'd like to colour the name of the list. As I understand that currently, this colours only the elements in a list:

[RichLabel("<color=#f54e42><label/>")] public List<MapDestination> destinationsAccessibleFromHere;

image but I'd like to colour the name of the list instead. I am using this colouring to colour code variables on prefabs that need to be filled in once the prefabs are placed and it'd be helpful if there was a way to colour the name of the list instead of its elements.

Thank you

TylerTemp commented 4 months ago

At the moment it can not. But it's already in plan #15


Edit:

Oh, unfortunately, changing a label of array/list itself requires an Editor level component, which requires you to enable SaintsEditor. enabling SaintsEditor WILL DISABLE meta attributes from NaughtyAttributes

Option one is (after this feature is added) to switch to SaintsEditor

Option two is to use SaintsArray/SaintsList which can work alone:

[RichLabel("<color=#f54e42><label/>"), SaintsArray]
public SaintsList<MapDestination> destinationsAccessibleFromHere;

private void Start() {
    // can be used like a list
    destinationsAccessibleFromHere.Add(default);
    foreach(var v in destinationsAccessibleFromHere)
    {
        Debug.Log(v);
    }
    // obtain the actual list:
    List<MapDestination> lis = destinationsAccessibleFromHere.value;
}

Edit 2:

Since you're also using NaughtyAttributes, the Label from it should work as expected I guess (with Unity's standard rich text)?

TylerTemp commented 4 months ago

Hi, since 2.3.9, it can be done with PlayaRichLabel (but it requires SaintsEditor)

There is some issue changing label for SaintsArray, SaintsList. Will be fixed on next release.

TylerTemp commented 4 months ago

Hi, since 2.4.2, there are several ways to do it.

Option 1

Enable SaintsEditor. This is the most "correct" way, but you'll no longer be able to use meta attributes from NaughtyAttributes

[PlayaRichLabel("<color=lame>It's Labeled!")]
public List<string> myList;

[PlayaRichLabel(nameof(MethodLabel), true)]
public string[] myArray;

// ReSharper disable once ParameterTypeCanBeEnumerable.Local
private string MethodLabel(string[] values)
{
    return $"<color=green><label /> {string.Join("", values.Select(_ => "<icon=star.png />"))}";
}

image

Option 2

Using SaintsArray/SaintsList, this is a struct wrapped array/list. Not recommended.

[RichLabel("<color=cyan><label /><icon=star.png />"), SaintsArray]
public SaintsList<GameObject> saintsListGo;

image

Because of the limitations of Unity, there does not have some better ways I can think of.


I'll close this issue as it's been implemented. If you had any issue using these, please open a new issue. If you have other ideas, please either open a new issue or comment on this one (and I'll open it again)