stride3d / stride3d/stride

Generic UIElement.FindName

Open
#2,652 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.