-
Notifications
You must be signed in to change notification settings - Fork 18
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
EditorWindow support #20
Comments
Hi, what are you trying to achieve using an |
I would like to define EditorWindow using UXML. But current generator only assume that whole tree is from UIDocument. |
Basically I think would be beneficial to have something like this // <autogenerated />
using UnityEngine;
using UnityEngine.UIElements;
public partial class SampleDocument : EditorWindow /* Derived class is not needed in codegen, that's for illustration */
{
public Label TitleLabel { get; private set; }
public Button Button { get; private set; }
public VisualElement Root
{
get
{
return rootVisualElement;
}
}
public void InitializeDocument()
{
TitleLabel = (Label)Root?.Q("TitleLabel");
Button = (Button)Root?.Q("Button");
}
} |
That is a very interesting usecase you got there. At the moment Rosalina doesn't support code generation for An alternative, would be to load the |
If you give me hints, I maybe can try to implement this. but I'm not Unity developer, just regular developer, even if experience one.
That's what I have right now. It's a bit of boilerplate and that's the reason want to get rid of |
I must think of a way to handle properly both cases (UI Document using MonoBehavior and UI Document with EditorWindow) so it doesn't break anything within the generator. Also, I believe we should work on issue #15 first and verify if it could work for |
I have been doing some research on how we could implement this feature and I might have found something. I believe we can use this option to tell Rosalina how to behave when generating the binding script since this option generates an XML attribute at the document root node: <ui:UXML ... editor-extension-mode="True">
</ui:UXML> We will need to create a new bindings generator for the |
I have been doing some research during the past couple of days about how we could implement the As an idea, there is a example of how the generated and user's code will look like: Auto-Generated codepublic partial class TestEditorWindow : EditorWindow
{
// Element properties
public Button SampleButton { get; private set; }
public void CreateGUI()
{
// VTA loading from assets
VisualTreeAsset uiAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/...");
VisualElement ui = uiAsset.CloneTree();
// Add to EditorWindow root visual element
rootVisualElement.Add(ui);
// Apply bindings
SampleButton = (Button)rootVisualElement?.Q("SampleButton");
// Call user specific code for event setup
OnCreateGUI();
}
private partial void OnCreateGUI();
} The initialization process of an User script codepublic partial class TestEditorWindow : EditorWindow
{
[MenuItem("Window/My Window")]
public static void ShowTestEditorWindow()
{
EditorWindow.CreateWindow<TestEditorWindow>();
}
private partial void OnCreateGUI()
{
SampleButton.clicked += SampleButtonClicked;
}
private void SampleButtonClicked() => Debug.Log("Button clicked");
} Note, the |
Shipped in version Closing issue. |
I think about using this package inside EditorWindow but cannot find a way how I can map UIDocument and EditorWindow.
The text was updated successfully, but these errors were encountered: