Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anosatsuk124/godotuixml
Godot UI Generator from XML
https://github.com/anosatsuk124/godotuixml
game-ui godot
Last synced: 25 days ago
JSON representation
Godot UI Generator from XML
- Host: GitHub
- URL: https://github.com/anosatsuk124/godotuixml
- Owner: anosatsuk124
- License: apache-2.0
- Created: 2024-07-31T01:10:10.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-08-02T10:48:10.000Z (5 months ago)
- Last Synced: 2024-10-30T00:15:30.569Z (2 months ago)
- Topics: game-ui, godot
- Language: C#
- Homepage:
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Godot UI Generator from XML
## Usage and Installation
### TLDR;
If you want to try the generator with examples, you just use the following commands.
```bash
git clone [email protected]:anosatsuk124/GodotUIXml.gitcd GodotUIXml
cd exmaplesfor f in $(find . -name '*.xml'); do dotnet run "$f" --project ../; done
```### Installation
```sh
git clone [email protected]:anosatsuk124/GodotUIXml.git
cd GodotUIXml
```### Usage
```sh
dotnet run /path/to/xml/File.xml
```🥳: That's it! The generated code will be saved as `File.generated.cs`.
## Sample Generated Code
> [!NOTE]
> For more detailed examples, see [`/Demo/UI`](https://github.com/anosatsuk124/GodotUIXml/tree/master/Demo/UI) and [`/Demo/SourcesGenerated`](https://github.com/anosatsuk124/GodotUIXml/tree/master/Demo/SourcesGenerated) directory.FileName: `TestNode.xml`
```xml
```
FileName: `TestNode.generated.cs`
```csharp
using Godot;public partial class TestNode : Node
{
// Only the elements with an `id` should be generated.
// The names and classes of the properties are determined by the `id` attribute and the element name.public Control root;
public Button unique1;
public Label unique2;
public RichTextLabel unique4;
public Label unique3;
public Label unique5;// All the local variable names are suffixed by the index numbers.
// `root_{index}` is a variable to `addChild`.
// `proto_scene` attribute is used to load the scene.
// `scene_{index}` is used to load the scene.
// `node_{index}` is used to instantiate a node.public override void _Ready()
{
var root_0 = this;
var scene_0 = GD.Load("res://my_window.tscn");
var node_0 = scene_0.Instantiate();
root = node_0;
root_0.AddChild(node_0);
var root_1 = node_0;
var node_1 = new Button();
unique1 = node_1;
node_1.Text = "Hello";
root_1.AddChild(node_1);
var root_2 = node_1;
var node_2 = new Label();
unique2 = node_2;
node_2.Text = "World";
root_2.AddChild(node_2);
var node_3 = new RichTextLabel();
unique4 = node_3;
root_2.AddChild(node_3);
var node_4 = new Label();
unique3 = node_4;
root_2.AddChild(node_4);
var node_5 = new Label();
unique5 = node_5;
root_1.AddChild(node_5);
var node_6 = new Button();
node_6.Text = "Hello No id";
root_1.AddChild(node_6);
var scene_1 = GD.Load("res://my_label.tscn");
var node_7 = scene_1.Instantiate();
root_1.AddChild(node_7);
}
}
```