[Unity] Adding controls to a canvas programmatically
I'm trying to add some controls to a Canvas element programmatically. In other XAML based frameworks, I'd simply create the control and add it to the Canvas's Children, like so:
However, this does not appear to work in Noesis GUI. The Canvas control doesn't expose a Children property. Is there any other way to add items programmatically?
Code: Select all
var button = new Button();
myCanvas.Children.Add(button);
-
sfernandez
Site Admin
- Posts: 3152
- Joined:
Re: [Unity] Adding controls to a canvas programmatically
Current Unity API exposes most of the functionality via methods, so to access the Children collection of a Panel you should call GetChildren():
We want to change this for 1.2 version, providing C# properties to access element properties, trying to follow WPF API as much as we can.
Code: Select all
var button = new Button();
myCanvas.GetChildren().Add(button);
Re: [Unity] Adding controls to a canvas programmatically
Thanks for the response! Any news on when 1.2 is out?
-
sfernandez
Site Admin
- Posts: 3152
- Joined:
Re: [Unity] Adding controls to a canvas programmatically
We are working hard because we are a bit late according to our planning.
I can't set an official date, but it will be soon.
I can't set an official date, but it will be soon.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest