您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
98 行
2.9 KiB
98 行
2.9 KiB
using System.Collections.Generic;
|
|
using uiwidgets;
|
|
using Unity.UIWidgets.engine;
|
|
using Unity.UIWidgets.material;
|
|
using Unity.UIWidgets.widgets;
|
|
|
|
namespace UIWidgetsSample.RaycastableScene
|
|
{
|
|
public class ItemPickerMainUIPanel : UIWidgetsRaycastablePanel
|
|
{
|
|
protected override void onEnable()
|
|
{
|
|
AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
|
|
}
|
|
|
|
protected override void main()
|
|
{
|
|
ui_.runApp(new ItemPickerMainUI());
|
|
}
|
|
}
|
|
|
|
public class ItemPickerMainUI : StatelessWidget
|
|
{
|
|
public override Widget build(BuildContext context)
|
|
{
|
|
return new MaterialApp(
|
|
home: new Scaffold(
|
|
backgroundColor: Colors.blue.withAlpha(64),
|
|
body: new ItemPickerMainWidget()
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
public class ItemPickerMainWidget : StatefulWidget
|
|
{
|
|
public override State createState()
|
|
{
|
|
return new ItemPickerMainWidgetState();
|
|
}
|
|
}
|
|
|
|
public class ItemPickerMainWidgetState : State<ItemPickerMainWidget>
|
|
{
|
|
public override Widget build(BuildContext context)
|
|
{
|
|
return new Column(
|
|
children: new List<Widget>
|
|
{
|
|
buildTop(),
|
|
buildMiddle()
|
|
}
|
|
);
|
|
}
|
|
|
|
private Widget buildTop()
|
|
{
|
|
return new RaycastableContainer(child: new SceneBoard());
|
|
}
|
|
|
|
private Widget buildMiddle()
|
|
{
|
|
return new Expanded(child: new Row(
|
|
children: new List<Widget>
|
|
{
|
|
buildLeft(),
|
|
new Container()
|
|
}
|
|
));
|
|
}
|
|
|
|
private Widget buildLeft()
|
|
{
|
|
return new RaycastableContainer(child: new Container(width: 100f, color: Colors.green.withAlpha(125), child: new LeftUIPanel(
|
|
itemNames: new List<PickListItem>
|
|
{
|
|
new PickListItem("cube1"),
|
|
new PickListItem("cube2"),
|
|
new PickListItem("cube3"),
|
|
new PickListItem("cube4"),
|
|
new PickListItem("ball1"),
|
|
new PickListItem("ball2"),
|
|
new PickListItem("ball3"),
|
|
new PickListItem("cylinder1"),
|
|
new PickListItem("cylinder2")
|
|
},
|
|
itemCheckCallback: (index, active) =>
|
|
{
|
|
//TODO: callback when item is activated/inactivated
|
|
},
|
|
itemSelectCallback: (index) =>
|
|
{
|
|
//TODO: callback when item is selected
|
|
}
|
|
)));
|
|
}
|
|
}
|
|
}
|