Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] [AddTypeMenu] with dynamic string value #64

Closed
Antoshidza opened this issue Aug 21, 2024 · 6 comments · Fixed by #74
Closed

[FEATURE] [AddTypeMenu] with dynamic string value #64

Antoshidza opened this issue Aug 21, 2024 · 6 comments · Fixed by #74
Assignees
Labels
enhancement New feature or request

Comments

@Antoshidza
Copy link

Antoshidza commented Aug 21, 2024

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:
image
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.

@Antoshidza Antoshidza added the enhancement New feature or request label Aug 21, 2024
@Antoshidza
Copy link
Author

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 Antoshidza changed the title [AddTypeMenu] with dynamic string value [FEATURE] [AddTypeMenu] with dynamic string value Sep 25, 2024
@mackysoft
Copy link
Owner

@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;
    }
}

@Antoshidza
Copy link
Author

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"

@mackysoft
Copy link
Owner

Is this what you want to do?

[SerializeReference, SubclasSelector(useAsToStringAsName = true)]
public IEffect effect;

@Antoshidza
Copy link
Author

Is this what you want to do?

[SerializeReference, SubclasSelector(useAsToStringAsName = true)]
public IEffect effect;

Yep

@mackysoft mackysoft linked a pull request Oct 26, 2024 that will close this issue
@mackysoft
Copy link
Owner

Functionality implemented. #74
Publish a release soon, just note that we are using UNITY_2021_3_OR_NEWER.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants