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

Inject behavior for the existing UI Toolkit VisualElements available in the scene #23

Merged
merged 2 commits into from
Jan 12, 2022

Conversation

mdm88
Copy link

@mdm88 mdm88 commented Jan 11, 2022

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

  • Extenject does no inject UI Toolkits VisualElement clases

What is the new behavior?

  • Extenject now does inject every UI Toolkits VisualElement added to the scene. It supports multiple UIDocuments.

Does this introduce a breaking change?

  • Yes
  • No

Other information

On which Unity version has this been tested?

  • 2021.2
  • 2020.4 LTS
  • 2020.3
  • 2020.2
  • 2020.1
  • 2019.4 LTS
  • 2019.3
  • 2019.2
  • 2019.1
  • 2018.4 LTS

Scripting backend:

  • Mono
  • IL2CPP

Note: Every pull request is tested on the Continuous Integration (CI) system to confirm that it works in Unity.

Ideally, the pull request will pass ("be green"). This means that all tests pass and there are no errors. However, it is not uncommon for the CI infrastructure itself to fail on specific platforms or for so-called "flaky" tests to fail ("be red"). Each CI failure must be manually inspected to determine the cause.

CI starts automatically when you open a pull request, but only Releasers/Collaborators can restart a CI run. If you believe CI is giving a false negative, ask a Releaser to restart the tests.

@doctorseus
Copy link

doctorseus commented Jan 11, 2022

I guess this is required when VisualElements are created by UI Toolkit itself when they are part of a uxml file definition?

The pull request description is a bit broad as I could also just create VisualElements at runtime using existing Extenject mechanism to support inject fields.

One thing to note is also that when you have the situation that you load a uxml file at runtime using Resources.Load<VisualTreeAsset>("...").CloneTree() it would then not have any injected fields I guess VS this situation here where it is already loaded on Scene start so they are available for injection.

@mdm88 mdm88 changed the title Inject UI Toolkit VisualElements Inject UI Toolkit VisualElements on scene Jan 12, 2022
@mdm88
Copy link
Author

mdm88 commented Jan 12, 2022

You are right, when creating VisualElements at runtime im using a simple factory. But this adds support for elements already added to the scene.

One thing to note is also that when you have the situation that you load a uxml file at runtime using Resources.Load("...").CloneTree() it would then not have any injected fields I guess VS this situation here where it is already loaded on Scene start so they are available for injection.

Its true, i didnt thought about that

@Mathijs-Bakker Mathijs-Bakker merged commit 197e0d5 into Mathijs-Bakker:master Jan 12, 2022
@Mathijs-Bakker
Copy link
Owner

You are right, when creating VisualElements at runtime im using a simple factory. But this adds support for elements already added to the scene.

One thing to note is also that when you have the situation that you load a uxml file at runtime using Resources.Load("...").CloneTree() it would then not have any injected fields I guess VS this situation here where it is already loaded on Scene start so they are available for injection.

Its true, i didnt thought about that

I don't have any experience with the 'new' UI toolkit. As I still encounter the 'the good old' UnityUI system.
I can see te use of this PR. So I am going to merge this into master.

For a Loading UXML/VisualTreeAsset injecting behavior will be something to dive into next.

@Mathijs-Bakker Mathijs-Bakker changed the title Inject UI Toolkit VisualElements on scene Inject behavior for the existing UI Toolkit VisualElements available in the scene Jan 12, 2022
@Mathijs-Bakker Mathijs-Bakker added the enhancement New feature or request label Jan 12, 2022
@Mathijs-Bakker Mathijs-Bakker self-requested a review January 12, 2022 14:53
Copy link
Owner

@Mathijs-Bakker Mathijs-Bakker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

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 this pull request may close these issues.

3 participants