Generic UIElement.FindName
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Is your feature request related to a problem? Please describe.
I would prefer a generic method than casting inline so I created a custom UIElementExtension class to do that. I Thought it could be added to Stride as well. This is simply a nice to have feature to match InstantiateElement<T>. When using UILibraries .
The use case is I am always trying to get named subcomponents of the UIElements when setting up UI behavior in code, and it would be nice if I could get the function to retrieve the type of UI element I am trying to find rather than casting it in the setup game logic.
Describe the solution you'd like
Implement this function into UIElement
public T FindName<T>(string name) where T: UIElement
{
return (T)FindName(name);
}
Describe alternatives you've considered
I am currently using
using Stride.UI;
public static class UIElementExtension
{
public static T FindName<T>(this UIElement uiElement, string name) where T: UIElement
{
return (T)uiElement.FindName(name);
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in UIElement beside the existing FindName method and the analogous InstantiateElement API. Add the requested generic lookup behavior, then verify that named UI elements are returned as the requested type while the existing non-generic lookup remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100