[FEATURE] `[AddTypeMenu]` with dynamic string value
Feature description
I have IEffect and some wrapper class like CompositeEffect which contains IEffect and IProvider<int> to repeat effect execution certain times. In editor it looks like this:
And when it not expanded I see only
Element 1 Composite Effect.
It would be perfect if I could see something like: Element 1 Composite Effect: Draw / Element 1 Draw (composite) / Element 1 Draw.
I think it could be down like Odin does in it's attributes, where we can specify method name to get string dynamically instead of specify const string value.
One another way would be to use additional bool useToStringAsName which would use ToString() method of instance (not affect dropdown list when selecting type)
@Antoshidza For example, is this good enough?
[SerializeReference, SubclassSelector]
[ArrayDrawer(CustomLabel = "{LabelName}")]
public List<Item> items1 = new();
[SerializeReference, SubclassSelector]
[ArrayDrawer(CustomLabel = "{ToString()}")]
public List<Item> items2 = new();
[System.Serializable]
public class Item
{
public string LabelName;
public int Value;
public override string ToString () {
return LabelName;
}
}
I'm talking not about customizing array drawing (which is also good way to enhance this package, but array drawing isn't a part of this package responsibilities), but about drawing selected subclass. In my example here it is "Composite Effect" which I'd rather would draw as "Draw card multiple"
Is this what you want to do?
[SerializeReference, SubclasSelector(useAsToStringAsName = true)]
public IEffect effect;
Is this what you want to do?
[SerializeReference, SubclasSelector(useAsToStringAsName = true)] public IEffect effect;
Yep
Functionality implemented. #74
Publish a release soon, just note that we are using UNITY_2021_3_OR_NEWER.