Comments (5)
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.
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.
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.
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.
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)
- Bug: Waiting for user code in MyBox.dll to finish executing HOT 3
- Crash in MySerializedProperty
- Constant errors with conditional field
- Enter Play mode being slower after install the package HOT 5
- Release with .unitypackage HOT 1
- Naming Conflit HOT 1
- Editor takes a long time in "MyEditorEvents.OnWillSaveAssets" HOT 4
- [ButtonMethod] not work in list item HOT 6
- Passing a List or Array to DefinedValues HOT 3
- ConditionalField does not work when RegexString is used on the same fields HOT 1
- Missing def for Attributes/DefinedValuesAttribute.cs HOT 1
- ConditionalFieldAttribute is rather slow HOT 3
- Suggestion: Help boxes
- Using [ConditonalField] causes Editor Button to be drawn twice HOT 2
- ReadOnly HOT 1
- MyEditorAudio.cs not found. HOT 1
- DefinedValues w. method is null HOT 4
- [ConditionalField] doesn't work with lists or arrays HOT 1
- Foldout doesn't work properly in child classes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mybox.