XAML to Unity 3D GUI Convertor 0.7
Design your GUI in Visual Studio or Sharp Develop:
Run this software and get Unity GUI Script code!
Make your final touch from the inspector:
XAML to Unity 3D GUI Convertor
XAML to Unity 3D GUI Convertor is a tool that converts the xaml code to Unity gui script. It saves you the time of changing your gui code over and over to get the suitable result.
Simply design your GUI in Visual Studio or Sharp Develop and then run the program and select the xaml file you designed and wala! You have Unity GUI script code.
This is on early stages and it will be updated.
Now there are some things you need to know:
This is not a designer, you will need to have Visual Studio or SharpDevelop to generate the xaml code.
Naming conventions are according to the names of the xaml controls, except for the tab-controls in which the Header attribute of the tab is used. Most of the errors you may face is because you have a control that is not named . Name them and it will work.
When inside a xaml canvas, the margins are ignored. Instead the canvas.top and canvas.left is used.
All controls should be children of the grid , and the grid should be the child of the Window or a Page tag. If you are using visual studio 2008, 2010 or Sharp Develop you shouldn’t be having any problems. Simply create a new WPF Window and drag your controls to the grid.
For the buttons and labels that have images, Texture2D variables are automatically declared in Unity Script. The name of the textures are the name of the image source files.
For ex. Aram.jpg will be:
public Texture2D Aram_jpg;
You will need to use the inspector menu of the script to drag and drop your textures from unity assets.
I hope the ui framework of unity 3.5 save all the trouble in future.
Please take a look at this list to figure which control resembles which:
XAML Code → Unity GUI
Canvas → Window
Button → Button
TextBlock → TextArea
TextBox → TextField
Label → Label
TabControl → Toolbar
Please click here to download:
619911–28254–$XAML to Unity 3D GUI Convertor 0.7.rar (53.3 KB)
Features and bug fixes:
v0.7
Now all controls have their properties visible in Inspector window.
A little status window at the bottom of the software.
v0.65
The controls are named automatically if the name attribute does not exist.
All control now have inspector properties except the ones inside the window ( will be implemented ).
v0.6:
Added support for image on Label and Button
v0.51:
Fixed the error when the values of the controls are float. *
v0.5: *
- Generates C# Code *
- Automatically creates windowID for window/drag-able window with condition *
- Automatically creates id for toolbars *
- Supported controls are: *
- Button (Supports both text and image ) *
- Label (Supports both text and image ) *
- TextField *
- TextArea *
- Toolbar (Support only text. TODO: Images) *
- Window, Drag-able Window *
The following features are not yet implemented: *
- JavaScript Code Generation *
- Box *
- Scrollbars *
- RepeatButton *
- PasswordField *
If you have any questions or problems you can post it here. *
Best Regards, *
Nice. This kind of tools does make it easier to design GUI. Thanks thanks.
Hay there, I have created a small gui in visual studio 2008. here is the code
<Window x:Class="Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1">
<Grid Height="195.326" Width="279.916">
<TabControl Margin="12,12,24.912,12" Name="TabControl1">
<TabItem Header="About" Name="TabItem1">
<Grid>
<Label Margin="9.228,9.997,13.073,12.304" Name="Label1">This is a quick test.</Label>
</Grid>
</TabItem>
<TabItem Header="Login">
<Grid Height="134.575">
<TextBox Height="23.07" Name="TextBox2" Margin="5,23.839,5.619,0" VerticalAlignment="Top" />
<Label Height="27.774" HorizontalAlignment="Left" Name="Label3" VerticalAlignment="Top" Width="79.207">User Name</Label>
<Label HorizontalAlignment="Left" Margin="0,43.833,0,61.52" Name="Label2" Width="79.207">Password</Label>
<TextBox Margin="6,0,4.619,36.143" Name="TextBox3" Height="28.453" VerticalAlignment="Bottom" />
<Button Height="25.377" HorizontalAlignment="Right" Margin="0,0,5.619,6" Name="Button1" VerticalAlignment="Bottom" Width="74.593">Login</Button>
</Grid>
</TabItem>
<TabItem Header="Register">
<Grid Height="134.575">
<TextBox Height="23.07" Margin="5,23.839,5.619,0" Name="TextBox1" VerticalAlignment="Top" />
<Label Height="27.774" HorizontalAlignment="Left" Name="Label4" VerticalAlignment="Top" Width="79.207">User Name</Label>
<Label HorizontalAlignment="Left" Margin="0,43.833,0,61.52" Name="Label5" Width="79.207">Password</Label>
<TextBox Height="28.453" Margin="6,0,4.619,36.143" Name="TextBox4" VerticalAlignment="Bottom" />
<Button Height="25.377" HorizontalAlignment="Right" Margin="0,0,5.619,6" Name="Button2" VerticalAlignment="Bottom" Width="74.593">Register</Button>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Window>
and for some reason the application continuisly bombs when I try convert it to unity C#
Thanks for posting the example. Let me try to look at it. I’ll see what I can do.
Ok. I figured out the problem and fixed it. It works with your current example.
Please try and let me know.
Thank you.
still doesn’t work with 0.51
Sorry I gave you the wrong code
<page x:Class="Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1">
<Grid Height="195.326" Width="279.916">
<TabControl Margin="12,12,24.912,12" Name="TabControl1">
<TabItem Header="About" Name="TabItem1">
<Grid>
<Label Margin="9.228,9.997,13.073,12.304" Name="Label1">This is a quick test.</Label>
</Grid>
</TabItem>
<TabItem Header="Login">
<Grid Height="134.575">
<TextBox Height="23.07" Name="TextBox2" Margin="5,23.839,5.619,0" VerticalAlignment="Top" />
<Label Height="27.774" HorizontalAlignment="Left" Name="Label3" VerticalAlignment="Top" Width="79.207">User Name</Label>
<Label HorizontalAlignment="Left" Margin="0,43.833,0,61.52" Name="Label2" Width="79.207">Password</Label>
<TextBox Margin="6,0,4.619,36.143" Name="TextBox3" Height="28.453" VerticalAlignment="Bottom" />
<Button Height="25.377" HorizontalAlignment="Right" Margin="0,0,5.619,6" Name="Button1" VerticalAlignment="Bottom" Width="74.593">Login</Button>
</Grid>
</TabItem>
<TabItem Header="Register">
<Grid Height="134.575">
<TextBox Height="23.07" Margin="5,23.839,5.619,0" Name="TextBox1" VerticalAlignment="Top" />
<Label Height="27.774" HorizontalAlignment="Left" Name="Label4" VerticalAlignment="Top" Width="79.207">User Name</Label>
<Label HorizontalAlignment="Left" Margin="0,43.833,0,61.52" Name="Label5" Width="79.207">Password</Label>
<TextBox Height="28.453" Margin="6,0,4.619,36.143" Name="TextBox4" VerticalAlignment="Bottom" />
<Button Height="25.377" HorizontalAlignment="Right" Margin="0,0,5.619,6" Name="Button2" VerticalAlignment="Bottom" Width="74.593">Register</Button>
</Grid>
</TabItem>
</TabControl>
</Grid>
</page>
Ok I found out the problem. Visual studio 2008 writes <page x:Class=“Page1” in stead of <Window x:Class=“Page1”
[quote=BrightNewWorlds[Jasonvdm];770718]
Sorry I gave you the wrong code
<page x:Class="Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1">
<Grid Height="195.326" Width="279.916">
<TabControl Margin="12,12,24.912,12" Name="TabControl1">
<TabItem Header="About" Name="TabItem1">
<Grid>
<Label Margin="9.228,9.997,13.073,12.304" Name="Label1">This is a quick test.</Label>
</Grid>
</TabItem>
<TabItem Header="Login">
<Grid Height="134.575">
<TextBox Height="23.07" Name="TextBox2" Margin="5,23.839,5.619,0" VerticalAlignment="Top" />
<Label Height="27.774" HorizontalAlignment="Left" Name="Label3" VerticalAlignment="Top" Width="79.207">User Name</Label>
<Label HorizontalAlignment="Left" Margin="0,43.833,0,61.52" Name="Label2" Width="79.207">Password</Label>
<TextBox Margin="6,0,4.619,36.143" Name="TextBox3" Height="28.453" VerticalAlignment="Bottom" />
<Button Height="25.377" HorizontalAlignment="Right" Margin="0,0,5.619,6" Name="Button1" VerticalAlignment="Bottom" Width="74.593">Login</Button>
</Grid>
</TabItem>
<TabItem Header="Register">
<Grid Height="134.575">
<TextBox Height="23.07" Margin="5,23.839,5.619,0" Name="TextBox1" VerticalAlignment="Top" />
<Label Height="27.774" HorizontalAlignment="Left" Name="Label4" VerticalAlignment="Top" Width="79.207">User Name</Label>
<Label HorizontalAlignment="Left" Margin="0,43.833,0,61.52" Name="Label5" Width="79.207">Password</Label>
<TextBox Height="28.453" Margin="6,0,4.619,36.143" Name="TextBox4" VerticalAlignment="Bottom" />
<Button Height="25.377" HorizontalAlignment="Right" Margin="0,0,5.619,6" Name="Button2" VerticalAlignment="Bottom" Width="74.593">Register</Button>
</Grid>
</TabItem>
</TabControl>
</Grid>
</page>
[/quote]
Ok. I see now what the problem is.
As I mentioned in the main post:
All controls should be the child of the grid, and the grid should be the child of the Window tag.
Which means that you need to use a Window file , not a page file.
But I will try to add page files to the support soon.
[quote=BrightNewWorlds[Jasonvdm];770722]
Ok I found out the problem. Visual studio 2008 writes <page x:Class=“Page1” in stead of <Window x:Class=“Page1”
[/quote]
oh, I was just replying to your previous post.
I just tested a VS 2008 WPF application. Please create a new wpf project and it automatically creates the
hm…,
Even your second code works here without any problems. Were you able to reproduce the problem with the “page” code?
OK it seems to work here now.
next problem. I see that the toolbar is not supported. this will be a great feature to include. can’t wait
Thanks for the speedy reply and quick fixes .
[quote=BrightNewWorlds[Jasonvdm];771215]
OK it seems to work here now.
next problem. I see that the toolbar is not supported. this will be a great feature to include. can’t wait
Thanks for the speedy reply and quick fixes .
[/quote]
You’re welcome. It already supports toolbars. Just use Tab Control in XAML.
Please take a look at this list to figure which control resembles which:
XAML Code → Unity GUI
Canvas → Window
Button → Button
TextBlock → TextArea
TextBox → TextField
Label → Label
TabControl → Toolbar
Hi Aram, is this project still active?
Seeing that this project seems to be dead I would like to present a professional alternative to the XAML to Unity approach, noesisGUI:
http://forum.unity3d.com/threads/192064-NoesisGUI-XAML-based-User-Interface-RELEASED
Welcome to our official discussion site. You’ll find topics on features, bugs, development, and general support here