Git Product home page Git Product logo

Comments (5)

Deadcows avatar Deadcows commented on June 12, 2024 1

Thank you a lot for the detailed explanation. I did ignored the UI Toolkit for too long for sure, it's time 😁. For the past few weeks I have been thinking about investing some time into it, and the info you shared is a good starting point.

I did some testing and I think it won't be too hard to implement. ButtonMethods was easy to fix, but I still need to reimplement Foldouts to make it work with the New UI until I'll be able to push the fix to the main branch.
Also, the layout is a bit off for some PropertyDrawers, I'll need to investigate that.

For now you can use the version from this branch

from mybox.

EmreDogann avatar EmreDogann commented on June 12, 2024 1

If the UI Toolkit inspectors work in older versions, then it could be an "invisible" change for those older versions (although in this case it would be safer to have it be an opt-in option). However, I'm not too familiar with the older versions of UI Toolkit, so I don't know how it interacts with inspectors or if they have changed things drastically with breaking backwards compatibility. With 2022.2+ making the UI Toolkit the default for the Editor UI at least, I'm assuming this means not as many breaking changes/API changes and is considered more "stable".

from mybox.

EmreDogann avatar EmreDogann commented on June 12, 2024

Wow, awesome! Thanks for the new branch! Yeah, I personally like the flexibility UI Toolkit gives you in either building the UI with UI Builder, or through code, or both.

An interesting thought I had, the use of UI Toolkit grants us the following ability: in theory you could supply an asset path to a .uxml file where you can author your own styling (e.g. a custom button layout). Something like this:

[ButtonMethod(styleOverride: "Asset/Editor/MyBox/CustomButtonMethod.uxml")]
private void Method() {
	...
}

// or

// In Tools -> MyBox -> MyBox Window -> Style Override Directory = "Asset/Editor/MyBox"
[ButtonMethod(styleOverride: "CustomButtonMethod.uxml")]
private void Method() {
	...
}

Then in ButtonMethodAttribute.cs you would load that path using AssetDatabase.LoadAssetAtPath<VisualTreeAsset> and incorporate it into the CreatePropertyGUI() function.

The issue here would be if the .uxml file was not setup correctly on the user's end it might cause the button to not work properly. There is a lot of things that could go wrong here haha 😵.

This could probably be hidden behind a UNITY_2022_2_OR_NEWER define to not bog down users on older versions.
This is probably overkill for MyBox, but was an interesting thought I had that I thought I might share.

from mybox.

Deadcows avatar Deadcows commented on June 12, 2024

Why do you think it's better to wrap it up with UNITY_2022_2_OR_NEWER?
I see that VisualElement was brought to Unity in 2019.1 🤔
Anyway, I should read the docs thoroughly first to better understand the whole thing 😁

from mybox.

Deadcows avatar Deadcows commented on June 12, 2024

I decided to finally start to use Odin Inspector, so to solve compatibility issues I simply made UnityObjectEditor optional. It is required for [ButtonMethod] and [Foldout] attributes to work though, but it looks like a viable sacrifice.

This change is on the main branch now

from mybox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.