|
|
|
|
|
|
A UIWidgets App is written in **C# Scripts**. Please follow the steps to create an App and play it |
|
|
|
in Unity Editor. |
|
|
|
|
|
|
|
1. Create a new C# Script named "ExampleCanvas.cs" and paste the following codes into it. |
|
|
|
1. Create a new C# Script named "UIWidgetsExample.cs" and paste the following codes into it. |
|
|
|
using Unity.UIWidgets.animation; |
|
|
|
using Unity.UIWidgets.engine; |
|
|
|
using Unity.UIWidgets.foundation; |
|
|
|
using Unity.UIWidgets.material; |
|
|
|
|
|
|
namespace UIWidgetsSample { |
|
|
|
public class ExampleCanvas : WidgetCanvas { |
|
|
|
public class UIWidgetsExample : UIWidgetsPanel { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override Widget getWidget() { |
|
|
|
return new ExampleApp(); |
|
|
|
|
|
|
|
protected override Widget createWidget() { |
|
|
|
return new WidgetsApp( |
|
|
|
home: new ExampleApp(), |
|
|
|
pageRouteBuilder: this.pageRouteBuilder); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual PageRouteFactory pageRouteBuilder { |
|
|
|
get { |
|
|
|
return (RouteSettings settings, WidgetBuilder builder) => |
|
|
|
new PageRouteBuilder( |
|
|
|
settings: settings, |
|
|
|
pageBuilder: (BuildContext context, Animation<float> animation, |
|
|
|
Animation<float> secondaryAnimation) => builder(context) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class ExampleApp : StatefulWidget { |
|
|
|
|
|
|
new GestureDetector( |
|
|
|
onTap: () => { |
|
|
|
this.setState(() |
|
|
|
=> { |
|
|
|
=> { |
|
|
|
this.counter++; |
|
|
|
}); |
|
|
|
}, |
|
|
|