浏览代码

WidgetCanvas => UIWidgetsPanel

/main
fzhangtj 6 年前
当前提交
0b003a69
共有 51 个文件被更改,包括 601 次插入581 次删除
  1. 2
      Editor/editor/WidgetCanvasEditor.cs
  2. 12
      Samples/MaterialSample/DividerButton.cs
  3. 10
      Samples/ReduxSample/CounterApp/CounterApp.unity
  4. 9
      Samples/ReduxSample/CounterApp/CounterAppSample.cs
  5. 9
      Samples/ReduxSample/ObjectFinder/ObjectFinderApp.cs
  6. 14
      Samples/UIWidgetSample/UIWidgetSample.unity
  7. 56
      Samples/UIWidgetSample/AsScreenSample.cs
  8. 16
      Samples/UIWidgetSample/CustomPaintSample.cs
  9. 28
      Samples/UIWidgetSample/DragDropSample.cs
  10. 11
      Samples/UIWidgetSample/ExpansionPanelSample.cs
  11. 11
      Samples/UIWidgetSample/MaterialSample.cs
  12. 25
      Samples/UIWidgetSample/NavigationSample.cs
  13. 19
      Samples/UIWidgetSample/TextInputSample.cs
  14. 14
      Samples/UIWidgetSample/ToDoAppSample.cs
  15. 323
      Runtime/engine/UIWidgetsPanel.cs
  16. 30
      Samples/UIWidgetSample/PageViewSample.cs
  17. 45
      Samples/UIWidgetSample/ScrollbarSample.cs
  18. 20
      Samples/UIWidgetSample/UIWidgetsSamplePanel.cs
  19. 11
      Samples/UIWidgetSample/UIWidgetsSamplePanel.cs.meta
  20. 45
      Samples/UIWidgetSample/Utils.cs
  21. 11
      Samples/UIWidgetSample/Utils.cs.meta
  22. 366
      Runtime/engine/WidgetCanvas.cs
  23. 6
      Samples/ReduxSample/ReduxSample.asmdef
  24. 7
      Samples/ReduxSample/ReduxSample.asmdef.meta
  25. 6
      Samples/UIWidgetSample/UIWidgetSample.asmdef
  26. 7
      Samples/UIWidgetSample/UIWidgetSample.asmdef.meta
  27. 27
      Samples/UIWidgetSample/PageViewCanvas.cs
  28. 42
      Samples/UIWidgetSample/ScrollbarCanvas.cs
  29. 0
      /Runtime/engine/UIWidgetsPanel.cs.meta
  30. 0
      /Samples/MaterialSample/DividerButton.cs.meta
  31. 0
      /Samples/MaterialSample/DividerButton.cs
  32. 0
      /Samples/ReduxSample/CounterApp/CounterAppSample.cs.meta
  33. 0
      /Samples/ReduxSample/CounterApp/CounterAppSample.cs
  34. 0
      /Samples/UIWidgetSample/AsScreenSample.cs.meta
  35. 0
      /Samples/UIWidgetSample/CustomPaintSample.cs.meta
  36. 0
      /Samples/UIWidgetSample/DragDropSample.cs.meta
  37. 0
      /Samples/UIWidgetSample/ExpansionPanelSample.cs.meta
  38. 0
      /Samples/UIWidgetSample/MaterialSample.cs.meta
  39. 0
      /Samples/UIWidgetSample/NavigationSample.cs.meta
  40. 0
      /Samples/UIWidgetSample/PageViewSample.cs.meta
  41. 0
      /Samples/UIWidgetSample/ScrollbarSample.cs.meta
  42. 0
      /Samples/UIWidgetSample/TextInputSample.cs.meta
  43. 0
      /Samples/UIWidgetSample/ToDoAppSample.cs.meta
  44. 0
      /Samples/UIWidgetSample/AsScreenSample.cs
  45. 0
      /Samples/UIWidgetSample/CustomPaintSample.cs
  46. 0
      /Samples/UIWidgetSample/DragDropSample.cs
  47. 0
      /Samples/UIWidgetSample/ExpansionPanelSample.cs
  48. 0
      /Samples/UIWidgetSample/MaterialSample.cs
  49. 0
      /Samples/UIWidgetSample/NavigationSample.cs
  50. 0
      /Samples/UIWidgetSample/TextInputSample.cs
  51. 0
      /Samples/UIWidgetSample/ToDoAppSample.cs

2
Editor/editor/WidgetCanvasEditor.cs


using UnityEditor.UI;
namespace Unity.UIWidgets.Editor {
[CustomEditor(typeof(WidgetCanvas), true)]
[CustomEditor(typeof(UIWidgetsPanel), true)]
[CanEditMultipleObjects]
public class WidgetCanvasEditor : RawImageEditor {
public override void OnInspectorGUI() {

12
Samples/MaterialSample/DividerButton.cs


using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {
public class DividerButtonCanvas : WidgetCanvas {
protected override Widget getWidget() {
return new DemoApp();
public class DividerButton : UIWidgetsSamplePanel {
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: new DemoApp(),
pageRouteBuilder: this.pageRouteBuilder,
window: window);
public class DemoApp : StatefulWidget {
public DemoApp(Key key = null) : base(key) {
}

10
Samples/ReduxSample/CounterApp/CounterApp.unity


m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 100}
m_SizeDelta: {x: 300, y: 200}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1059242951
MonoBehaviour:

m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
--- !u!222 &1059242952
CanvasRenderer:
m_ObjectHideFlags: 0

9
Samples/ReduxSample/CounterApp/CounterAppSample.cs


using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.Sample.Redux {
public class CounterAppCanvas : WidgetCanvas {
protected override Widget getWidget() {
return new CounterApp();
public class CounterAppSample : UIWidgetsSample.UIWidgetsSamplePanel {
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: new CounterApp(),
pageRouteBuilder: this.pageRouteBuilder,
window: window);
}
}

9
Samples/ReduxSample/ObjectFinder/ObjectFinderApp.cs


using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.Sample.Redux.ObjectFinder {
public class ObjectFinderApp : WidgetCanvas {
public class ObjectFinderApp : UIWidgetsSample.UIWidgetsSamplePanel {
protected override Widget getWidget() {
return new StoreProvider<FinderAppState>(StoreProvider.store, this.createWidget());
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: new StoreProvider<FinderAppState>(StoreProvider.store, this.createWidget()),
pageRouteBuilder: this.pageRouteBuilder,
window: window);
}
Widget createWidget() {

14
Samples/UIWidgetSample/UIWidgetSample.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074, b: 0.35872698, a: 1}
m_IndirectSpecularColor: {r: 0.37311947, g: 0.38074, b: 0.35872698, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:

y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
--- !u!222 &432951248
CanvasRenderer:
m_ObjectHideFlags: 0

y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
--- !u!222 &552752113
CanvasRenderer:
m_ObjectHideFlags: 0

y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
--- !u!222 &895510408
CanvasRenderer:
m_ObjectHideFlags: 0

y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
--- !u!222 &1199742534
CanvasRenderer:
m_ObjectHideFlags: 0

m_Father: {fileID: 304189374}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_SizeDelta: {x: 600, y: 300}
m_SizeDelta: {x: -20, y: -20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1387978528
MonoBehaviour:

y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
--- !u!222 &1387978529
CanvasRenderer:
m_ObjectHideFlags: 0

y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
--- !u!222 &1628409009
CanvasRenderer:
m_ObjectHideFlags: 0

56
Samples/UIWidgetSample/AsScreenSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {
public class AsScreenCanvas : WidgetCanvas {
protected override Widget getWidget() {
return new AsScreen();
public class AsScreenSample : UIWidgetsSamplePanel {
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: new AsScreenWidget(),
pageRouteBuilder: this.pageRouteBuilder,
window: window);
public class AsScreen : StatefulWidget {
public AsScreen(Key key = null) : base(key) {
public class AsScreenWidget : StatefulWidget {
public AsScreenWidget(Key key = null) : base(key) {
}
public override State createState() {

class _AsScreenState : State<AsScreen> {
class _AsScreenState : State<AsScreenWidget> {
const float headerHeight = 50.0f;
Widget _buildHeader(BuildContext context) {

);
return container;
}
}
public static class Icons {
public static readonly IconData notifications = new IconData(0xe7f4, fontFamily: "Material Icons");
public static readonly IconData account_circle = new IconData(0xe853, fontFamily: "Material Icons");
public static readonly IconData search = new IconData(0xe8b6, fontFamily: "Material Icons");
public static readonly IconData keyboard_arrow_down = new IconData(0xe313, fontFamily: "Material Icons");
}
public static class CLColors {
public static readonly Color primary = new Color(0xFFE91E63);
public static readonly Color secondary1 = new Color(0xFF00BCD4);
public static readonly Color secondary2 = new Color(0xFFF0513C);
public static readonly Color background1 = new Color(0xFF292929);
public static readonly Color background2 = new Color(0xFF383838);
public static readonly Color background3 = new Color(0xFFF5F5F5);
public static readonly Color background4 = new Color(0xFF00BCD4);
public static readonly Color icon1 = new Color(0xFFFFFFFF);
public static readonly Color icon2 = new Color(0xFFA4A4A4);
public static readonly Color text1 = new Color(0xFFFFFFFF);
public static readonly Color text2 = new Color(0xFFD8D8D8);
public static readonly Color text3 = new Color(0xFF959595);
public static readonly Color text4 = new Color(0xFF002835);
public static readonly Color text5 = new Color(0xFF9E9E9E);
public static readonly Color text6 = new Color(0xFF002835);
public static readonly Color text7 = new Color(0xFF5A5A5B);
public static readonly Color text8 = new Color(0xFF239988);
public static readonly Color text9 = new Color(0xFFB3B5B6);
public static readonly Color text10 = new Color(0xFF00BCD4);
public static readonly Color dividingLine1 = new Color(0xFF666666);
public static readonly Color dividingLine2 = new Color(0xFF404040);
public static readonly Color transparent = new Color(0x00000000);
public static readonly Color white = new Color(0xFFFFFFFF);
public static readonly Color black = new Color(0xFF000000);
public static readonly Color red = new Color(0xFFFF0000);
public static readonly Color green = new Color(0xFF00FF00);
public static readonly Color blue = new Color(0xFF0000FF);
public static readonly Color header = new Color(0xFF060B0C);
}
}
}

16
Samples/UIWidgetSample/CustomPaintSample.cs


using Unity.UIWidgets.engine;
public class CustomPaintCanvas : WidgetCanvas {
protected override Widget getWidget() {
return new CustomPaint(
child: new Container(width: 300, height: 300, color: new Color(0XFFFFFFFF)),
foregroundPainter: new GridPainter(null)
);
public class CustomPaintSample : UIWidgetsSamplePanel {
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: new Unity.UIWidgets.widgets.CustomPaint(
child: new Container(width: 300, height: 300, color: new Color(0XFFFFFFFF)),
foregroundPainter: new GridPainter(null)
),
pageRouteBuilder: this.pageRouteBuilder,
window: window);
}
}

28
Samples/UIWidgetSample/DragDropSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;

namespace UIWidgetsSample {
public class DragDropCanvas : WidgetCanvas {
protected override Widget getWidget() {
return new DragDropApp();
public class DragDropSample : UIWidgetsSamplePanel {
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: new DragDropApp(),
pageRouteBuilder: this.pageRouteBuilder,
window: window);
}
class DragDropApp : StatefulWidget {

width: 40.0f,
height: 40.0f,
constraints: BoxConstraints.tight(new Size(40, 40)),
color: AsScreenCanvas.CLColors.red,
color: CLColors.red,
child: new Center(child: new Text("" + this.value))
);
}

var entry_bg = new OverlayEntry(
inner_context => new Container(
color: AsScreenCanvas.CLColors.white
color: CLColors.white
));
var entry = new OverlayEntry(

child: new Draggable<int>(
5,
child: new Container(
color: AsScreenCanvas.CLColors.blue,
color: CLColors.blue,
width: 30.0f,
height: 30.0f,
constraints: BoxConstraints.tight(new Size(30, 30)),

color: AsScreenCanvas.CLColors.green,
color: CLColors.green,
color: AsScreenCanvas.CLColors.black,
color: CLColors.black,
width: 30.0f,
height: 30.0f,
constraints: BoxConstraints.tight(new Size(30, 30))

new Draggable<int>(
8,
child: new Container(
color: AsScreenCanvas.CLColors.background4,
color: CLColors.background4,
width: 30.0f,
height: 30.0f,
constraints: BoxConstraints.tight(new Size(30, 30)),

color: AsScreenCanvas.CLColors.green,
color: CLColors.green,
color: AsScreenCanvas.CLColors.black,
color: CLColors.black,
width: 30.0f,
height: 30.0f,
constraints: BoxConstraints.tight(new Size(30, 30))

entries.Add(entry3);
return new Container(
color: AsScreenCanvas.CLColors.white,
color: CLColors.white,
child: new Overlay(
initialEntries: entries
)

11
Samples/UIWidgetSample/ExpansionPanelSample.cs


using Material = Unity.UIWidgets.material.Material;
namespace UIWidgetsSample {
public class ExpansionPanelCanvas : WidgetCanvas {
public class ExpansionPanelSample : UIWidgetsSamplePanel {
int testCaseId = 1;
readonly List<Widget> testCases = new List<Widget> {

protected override Widget getWidget() {
return this.testCases[this.testCaseId];
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: this.testCases[this.testCaseId],
pageRouteBuilder: this.pageRouteBuilder,
window: window);
}
}

width: 40.0f,
height: 40.0f,
constraints: BoxConstraints.tight(new Size(40, 600)),
color: AsScreenCanvas.CLColors.red,
color: CLColors.red,
child: new Center(child: new Text("Beijing"))
)
)

11
Samples/UIWidgetSample/MaterialSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;

public class MaterialCanvas : WidgetCanvas {
public class MaterialSample : UIWidgetsSamplePanel {
int testCaseId = 0;
List<Widget> testCases = new List<Widget> {

protected override Widget getWidget() {
return this.testCases[this.testCaseId];
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: this.testCases[this.testCaseId],
pageRouteBuilder: this.pageRouteBuilder,
window: window);
}
}

25
Samples/UIWidgetSample/NavigationSample.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

namespace UIWidgetsSample {
public class NavigationCanvas : WidgetCanvas {
protected override string initialRoute {
get { return "/"; }
}
public class NavigationSample : UIWidgetsSamplePanel {
protected override Dictionary<string, WidgetBuilder> routes {
get {
return new Dictionary<string, WidgetBuilder> {
protected override Widget createWidget(Window window) {
return new WidgetsApp(
initialRoute: "/",
textStyle: new TextStyle(fontSize: 24),
pageRouteBuilder: this.pageRouteBuilder,
routes: new Dictionary<string, WidgetBuilder> {
};
}
}
protected override TextStyle textStyle {
get { return new TextStyle(fontSize: 24); }
},
window: window);
protected override PageRouteFactory pageRouteBuilder {
get {
return (RouteSettings settings, WidgetBuilder builder) =>

19
Samples/UIWidgetSample/TextInputSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {
public class TextInputCanvas : WidgetCanvas {
public class TextInputSample : StatefulWidget {
public class TextInputSample : UIWidgetsSamplePanel {
class _TextInputSample : StatefulWidget {
public TextInputSample(Key key = null, string title = null) : base(key) {
public _TextInputSample(Key key = null, string title = null) : base(key) {
this.title = title;
}

}
protected override Widget getWidget() {
return new EditableInputTypeWidget();
// return new TextInputSample(key: null, title: this.gameObject.name);
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: new EditableInputTypeWidget(),
pageRouteBuilder: this.pageRouteBuilder,
window: window);
class _TextInputSampleState : State<TextInputSample> {
class _TextInputSampleState : State<_TextInputSample> {
TextEditingController titleController = new TextEditingController("");
TextEditingController descController = new TextEditingController("");
FocusNode _titleFocusNode;

14
Samples/UIWidgetSample/ToDoAppSample.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;

using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {
public class ToDoAppCanvas : WidgetCanvas {
public class ToDoAppSample : UIWidgetsSamplePanel {
public class ToDoListApp : StatefulWidget {
public ToDoListApp(Key key = null) : base(key) {
}

}
}
protected override Widget getWidget() {
return new ToDoListApp();
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: new ToDoListApp(),
pageRouteBuilder: this.pageRouteBuilder,
window: window);
}
public class CustomButton : StatelessWidget {

) : base(key: key) {
this.onPressed = onPressed;
this.padding = padding ?? EdgeInsets.all(8.0f);
this.backgroundColor = backgroundColor ?? AsScreenCanvas.CLColors.transparent;
this.backgroundColor = backgroundColor ?? CLColors.transparent;
this.child = child;
}

) : base(key: key) {
this.onPressed = onPressed;
this.padding = padding ?? EdgeInsets.all(8.0f);
this.backgroundColor = backgroundColor ?? AsScreenCanvas.CLColors.transparent;
this.backgroundColor = backgroundColor ?? CLColors.transparent;
this.child = child;
}

323
Runtime/engine/UIWidgetsPanel.cs


using System.Collections.Generic;
using Unity.UIWidgets.async;
using Unity.UIWidgets.editor;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using RawImage = UnityEngine.UI.RawImage;
using Rect = UnityEngine.Rect;
namespace Unity.UIWidgets.engine {
public class UIWidgetWindowAdapter : WindowAdapter {
readonly UIWidgetsPanel _uiWidgetsPanel;
bool _needsPaint;
protected override void updateSafeArea() {
this._padding = new WindowPadding(
Screen.safeArea.x,
Screen.safeArea.y,
Screen.width - Screen.safeArea.width,
Screen.height - Screen.safeArea.height);
}
public override void scheduleFrame(bool regenerateLayerTree = true) {
base.scheduleFrame(regenerateLayerTree);
this._needsPaint = true;
}
public UIWidgetWindowAdapter(UIWidgetsPanel uiWidgetsPanel) {
this._uiWidgetsPanel = uiWidgetsPanel;
}
public override void OnGUI(Event evt) {
if (this.displayMetricsChanged()) {
this._needsPaint = true;
}
if (evt.type == EventType.Repaint) {
if (!this._needsPaint) {
return;
}
this._needsPaint = false;
}
base.OnGUI(evt);
}
protected override Surface createSurface() {
return new EditorWindowSurface(this._uiWidgetsPanel.applyRenderTexture);
}
public override GUIContent titleContent {
get { return new GUIContent(this._uiWidgetsPanel.gameObject.name); }
}
protected override float queryDevicePixelRatio() {
return this._uiWidgetsPanel.devicePixelRatio;
}
protected override Vector2 queryWindowSize() {
var rect = RectTransformUtility.PixelAdjustRect(this._uiWidgetsPanel.rectTransform,
this._uiWidgetsPanel.canvas);
var size = new Vector2(rect.width, rect.height) / this._uiWidgetsPanel.devicePixelRatio;
size.x = Mathf.Round(size.x);
size.y = Mathf.Round(size.y);
return size;
}
}
[RequireComponent(typeof(RectTransform))]
public class UIWidgetsPanel : RawImage, IPointerDownHandler, IPointerUpHandler, IDragHandler,
IPointerEnterHandler, IPointerExitHandler {
static Event _repaintEvent;
[SerializeField] protected float devicePixelRatioOverride;
WindowAdapter _windowAdapter;
Texture _texture;
Vector2 _lastMouseMove;
HashSet<int> _enteredPointers;
bool _mouseEntered {
get { return !this._enteredPointers.isEmpty(); }
}
readonly ScrollInput _scrollInput = new ScrollInput();
DisplayMetrics _displayMetrics;
const int mouseButtonNum = 3;
protected override void OnEnable() {
base.OnEnable();
//Disable the default touch -> mouse event conversion on mobile devices
Input.simulateMouseWithTouches = false;
this._displayMetrics = DisplayMetricsProvider.provider();
if (_repaintEvent == null) {
_repaintEvent = new Event {type = EventType.Repaint};
}
D.assert(this._windowAdapter == null);
this._windowAdapter = new UIWidgetWindowAdapter(this);
this._windowAdapter.OnEnable();
this._windowAdapter.attachRootWidget(this.createWidget(this._windowAdapter));
this._lastMouseMove = Input.mousePosition;
this._enteredPointers = new HashSet<int>();
}
public float devicePixelRatio {
get {
return this.devicePixelRatioOverride > 0
? this.devicePixelRatioOverride
: this._displayMetrics.DevicePixelRatio;
}
}
protected override void OnDisable() {
D.assert(this._windowAdapter != null);
this._windowAdapter.OnDisable();
this._windowAdapter = null;
base.OnDisable();
}
protected virtual Widget createWidget(Window window) {
return null;
}
internal void applyRenderTexture(Rect screenRect, Texture texture, Material mat) {
this.texture = texture;
this.material = mat;
}
void Update() {
this._displayMetrics.Update();
if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != this.gameObject) {
this.unfocusIfNeeded();
}
if (this._mouseEntered) {
if (this._lastMouseMove.x != Input.mousePosition.x || this._lastMouseMove.y != Input.mousePosition.y) {
this.handleMouseMovement();
}
}
this._lastMouseMove = Input.mousePosition;
if (this._mouseEntered) {
this.handleMouseScroll();
}
D.assert(this._windowAdapter != null);
this._windowAdapter.Update();
this._windowAdapter.OnGUI(_repaintEvent);
}
void OnGUI() {
this._displayMetrics.OnGUI();
if (Event.current.type == EventType.KeyDown || Event.current.type == EventType.KeyUp) {
this._windowAdapter.OnGUI(Event.current);
}
}
void handleMouseMovement() {
var pos = this.getPointPosition(Input.mousePosition);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: PointerDeviceKind.mouse,
device: this.getMouseButtonDown(),
physicalX: pos.x,
physicalY: pos.y
));
}
void handleMouseScroll() {
if (Input.mouseScrollDelta.y != 0 || Input.mouseScrollDelta.x != 0) {
var scaleFactor = this.canvas.scaleFactor;
var pos = this.getPointPosition(Input.mousePosition);
this._scrollInput.onScroll(Input.mouseScrollDelta.x * scaleFactor,
Input.mouseScrollDelta.y * scaleFactor,
pos.x,
pos.y,
InputUtils.getScrollButtonKey());
}
var deltaScroll = this._scrollInput.getScrollDelta();
if (deltaScroll != Vector2.zero) {
this._windowAdapter.postPointerEvent(new ScrollData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.scroll,
kind: PointerDeviceKind.mouse,
device: this._scrollInput.getDeviceId(),
physicalX: this._scrollInput.getPointerPosX(),
physicalY: this._scrollInput.getPointerPosY(),
scrollX: deltaScroll.x,
scrollY: deltaScroll.y
));
}
}
int getMouseButtonDown() {
for (int key = 0; key < mouseButtonNum; key++) {
if (Input.GetMouseButton(key)) {
return InputUtils.getMouseButtonKey(key);
}
}
return 0;
}
public void OnPointerDown(PointerEventData eventData) {
EventSystem.current.SetSelectedGameObject(this.gameObject, eventData);
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.down,
kind: InputUtils.getPointerDeviceKind(eventData),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.x,
physicalY: position.y
));
}
public void OnPointerUp(PointerEventData eventData) {
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.up,
kind: InputUtils.getPointerDeviceKind(eventData),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.x,
physicalY: position.y
));
}
public Vector2 getPointPosition(PointerEventData eventData) {
Vector2 localPoint;
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rectTransform, eventData.position,
eventData.enterEventCamera, out localPoint);
var scaleFactor = this.canvas.scaleFactor;
localPoint.x = (localPoint.x - this.rectTransform.rect.min.x) * scaleFactor;
localPoint.y = (this.rectTransform.rect.max.y - localPoint.y) * scaleFactor;
return localPoint;
}
public Vector2 getPointPosition(Vector2 position) {
Vector2 localPoint;
Camera eventCamera = null;
if (this.canvas.renderMode != RenderMode.ScreenSpaceCamera) {
eventCamera = this.canvas.GetComponent<GraphicRaycaster>().eventCamera;
}
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rectTransform, position,
eventCamera, out localPoint);
var scaleFactor = this.canvas.scaleFactor;
localPoint.x = (localPoint.x - this.rectTransform.rect.min.x) * scaleFactor;
localPoint.y = (this.rectTransform.rect.max.y - localPoint.y) * scaleFactor;
return localPoint;
}
public void OnDrag(PointerEventData eventData) {
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.move,
kind: InputUtils.getPointerDeviceKind(eventData),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.x,
physicalY: position.y
));
}
public void OnPointerEnter(PointerEventData eventData) {
var pointerKey = InputUtils.getPointerDeviceKey(eventData);
this._enteredPointers.Add(pointerKey);
this._lastMouseMove = eventData.position;
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: InputUtils.getPointerDeviceKind(eventData),
device: pointerKey,
physicalX: position.x,
physicalY: position.y
));
}
public void OnPointerExit(PointerEventData eventData) {
var pointerKey = InputUtils.getPointerDeviceKey(eventData);
this._enteredPointers.Remove(pointerKey);
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: InputUtils.getPointerDeviceKind(eventData),
device: pointerKey,
physicalX: position.x,
physicalY: position.y
));
}
void unfocusIfNeeded() {
using (this._windowAdapter.getScope()) {
var focusNode = WidgetsBinding.instance.focusManager.currentFocus;
if (focusNode != null) {
focusNode.unfocus();
}
}
}
}
}

30
Samples/UIWidgetSample/PageViewSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace UIWidgetsSample {
public class PageViewSample : UIWidgetsSamplePanel {
protected override Widget createWidget(Window window) {
return new WidgetsApp(
home: new Container(
width: 200,
height: 400,
child: new PageView(
children: new List<Widget>() {
new Container(
color: new Color(0xFFE91E63)
),
new Container(
color: new Color(0xFF00BCD4)
),
new Container(
color: new Color(0xFF673AB7)
)
}
)),
pageRouteBuilder: this.pageRouteBuilder,
window: window);
}
}
}

45
Samples/UIWidgetSample/ScrollbarSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace UIWidgetsSample {
public class ScrollbarSample : UIWidgetsSamplePanel {
protected override Widget createWidget(Window window) {
var scroll = new Container(
decoration: new BoxDecoration(
border: Border.all(color: new Color(0xFFFFFF00))
),
child: new Scrollbar(
child: new ListView(
children: new List<Widget> {
new Container(height: 40.0f, child: new Text("0")),
new Container(height: 40.0f, child: new Text("1")),
new Container(height: 40.0f, child: new Text("2")),
new Container(height: 40.0f, child: new Text("3")),
new Container(height: 40.0f, child: new Text("4")),
new Container(height: 40.0f, child: new Text("5")),
new Container(height: 40.0f, child: new Text("6")),
new Container(height: 40.0f, child: new Text("7")),
new Container(height: 40.0f, child: new Text("8")),
new Container(height: 40.0f, child: new Text("9")),
new Container(height: 40.0f, child: new Text("10")),
new Container(height: 40.0f, child: new Text("11")),
new Container(height: 40.0f, child: new Text("12")),
new Container(height: 40.0f, child: new Text("13")),
new Container(height: 40.0f, child: new Text("14")),
new Container(height: 40.0f, child: new Text("15")),
new Container(height: 40.0f, child: new Text("16")),
new Container(height: 40.0f, child: new Text("17")),
}
)
)
);
return new WidgetsApp(
home: scroll,
pageRouteBuilder: this.pageRouteBuilder,
window: window);
}
}
}

20
Samples/UIWidgetSample/UIWidgetsSamplePanel.cs


using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.widgets;
namespace UIWidgetsSample {
public class UIWidgetsSamplePanel: UIWidgetsPanel {
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)
);
}
}
}
}

11
Samples/UIWidgetSample/UIWidgetsSamplePanel.cs.meta


fileFormatVersion: 2
guid: 4a21c5e1a50e24057a4ecf249fa86c1f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

45
Samples/UIWidgetSample/Utils.cs


using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace UIWidgetsSample {
public static class Icons {
public static readonly IconData notifications = new IconData(0xe7f4, fontFamily: "Material Icons");
public static readonly IconData account_circle = new IconData(0xe853, fontFamily: "Material Icons");
public static readonly IconData search = new IconData(0xe8b6, fontFamily: "Material Icons");
public static readonly IconData keyboard_arrow_down = new IconData(0xe313, fontFamily: "Material Icons");
}
public static class CLColors {
public static readonly Color primary = new Color(0xFFE91E63);
public static readonly Color secondary1 = new Color(0xFF00BCD4);
public static readonly Color secondary2 = new Color(0xFFF0513C);
public static readonly Color background1 = new Color(0xFF292929);
public static readonly Color background2 = new Color(0xFF383838);
public static readonly Color background3 = new Color(0xFFF5F5F5);
public static readonly Color background4 = new Color(0xFF00BCD4);
public static readonly Color icon1 = new Color(0xFFFFFFFF);
public static readonly Color icon2 = new Color(0xFFA4A4A4);
public static readonly Color text1 = new Color(0xFFFFFFFF);
public static readonly Color text2 = new Color(0xFFD8D8D8);
public static readonly Color text3 = new Color(0xFF959595);
public static readonly Color text4 = new Color(0xFF002835);
public static readonly Color text5 = new Color(0xFF9E9E9E);
public static readonly Color text6 = new Color(0xFF002835);
public static readonly Color text7 = new Color(0xFF5A5A5B);
public static readonly Color text8 = new Color(0xFF239988);
public static readonly Color text9 = new Color(0xFFB3B5B6);
public static readonly Color text10 = new Color(0xFF00BCD4);
public static readonly Color dividingLine1 = new Color(0xFF666666);
public static readonly Color dividingLine2 = new Color(0xFF404040);
public static readonly Color transparent = new Color(0x00000000);
public static readonly Color white = new Color(0xFFFFFFFF);
public static readonly Color black = new Color(0xFF000000);
public static readonly Color red = new Color(0xFFFF0000);
public static readonly Color green = new Color(0xFF00FF00);
public static readonly Color blue = new Color(0xFF0000FF);
public static readonly Color header = new Color(0xFF060B0C);
}
}

11
Samples/UIWidgetSample/Utils.cs.meta


fileFormatVersion: 2
guid: 3781c9e4efebd4c928ef175761d31b58
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

366
Runtime/engine/WidgetCanvas.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async;
using Unity.UIWidgets.editor;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using RawImage = UnityEngine.UI.RawImage;
using Rect = UnityEngine.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.engine {
public class UIWidgetWindowAdapter : WindowAdapter {
readonly WidgetCanvas _widgetCanvas;
bool _needsPaint;
protected override void updateSafeArea() {
this._padding = new WindowPadding(
Screen.safeArea.x,
Screen.safeArea.y,
Screen.width - Screen.safeArea.width,
Screen.height - Screen.safeArea.height);
}
public override void scheduleFrame(bool regenerateLayerTree = true) {
base.scheduleFrame(regenerateLayerTree);
this._needsPaint = true;
}
public UIWidgetWindowAdapter(WidgetCanvas widgetCanvas) {
this._widgetCanvas = widgetCanvas;
}
public override void OnGUI(Event evt) {
if (this.displayMetricsChanged()) {
this._needsPaint = true;
}
if (evt.type == EventType.Repaint) {
if (!this._needsPaint) {
return;
}
this._needsPaint = false;
}
base.OnGUI(evt);
}
protected override Surface createSurface() {
return new EditorWindowSurface(this._widgetCanvas.applyRenderTexture);
}
public override GUIContent titleContent {
get { return new GUIContent(this._widgetCanvas.gameObject.name); }
}
protected override float queryDevicePixelRatio() {
return this._widgetCanvas.devicePixelRatio;
}
protected override Vector2 queryWindowSize() {
var rect = RectTransformUtility.PixelAdjustRect(this._widgetCanvas.rectTransform,
this._widgetCanvas.canvas);
var size = new Vector2(rect.width, rect.height) / this._widgetCanvas.devicePixelRatio;
size.x = Mathf.Round(size.x);
size.y = Mathf.Round(size.y);
return size;
}
}
[RequireComponent(typeof(RectTransform))]
public abstract class WidgetCanvas : RawImage, IPointerDownHandler, IPointerUpHandler, IDragHandler,
IPointerEnterHandler, IPointerExitHandler {
static Event _repaintEvent;
[SerializeField] protected float devicePixelRatioOverride;
WindowAdapter _windowAdapter;
Texture _texture;
Vector2 _lastMouseMove;
HashSet<int> _enteredPointers;
bool _mouseEntered {
get { return !this._enteredPointers.isEmpty(); }
}
readonly ScrollInput _scrollInput = new ScrollInput();
DisplayMetrics _displayMetrics;
const int mouseButtonNum = 3;
protected override void OnEnable() {
base.OnEnable();
//Disable the default touch -> mouse event conversion on mobile devices
Input.simulateMouseWithTouches = false;
this._displayMetrics = DisplayMetricsProvider.provider();
if (_repaintEvent == null) {
_repaintEvent = new Event {type = EventType.Repaint};
}
D.assert(this._windowAdapter == null);
this._windowAdapter = new UIWidgetWindowAdapter(this);
this._windowAdapter.OnEnable();
var root = new WidgetsApp(
home: this.getWidget(),
window: this._windowAdapter,
routes: this.routes,
textStyle: this.textStyle,
pageRouteBuilder: this.pageRouteBuilder,
onGenerateRoute: this.onGenerateRoute,
onUnknownRoute: this.onUnknownRoute);
this._windowAdapter.attachRootWidget(root);
this._lastMouseMove = Input.mousePosition;
this._enteredPointers = new HashSet<int>();
}
public float devicePixelRatio {
get {
return this.devicePixelRatioOverride > 0
? this.devicePixelRatioOverride
: this._displayMetrics.DevicePixelRatio;
}
}
protected virtual Dictionary<string, WidgetBuilder> routes {
get { return null; }
}
protected virtual string initialRoute {
get { return null; }
}
protected virtual RouteFactory onGenerateRoute {
get { return null; }
}
protected virtual RouteFactory onUnknownRoute {
get { return null; }
}
protected virtual TextStyle textStyle {
get { return null; }
}
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)
);
}
}
protected override void OnDisable() {
D.assert(this._windowAdapter != null);
this._windowAdapter.OnDisable();
this._windowAdapter = null;
base.OnDisable();
}
protected virtual Widget getWidget() {
return null;
}
internal void applyRenderTexture(Rect screenRect, Texture texture, Material mat) {
this.texture = texture;
this.material = mat;
}
void Update() {
this._displayMetrics.Update();
if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != this.gameObject) {
this.unfocusIfNeeded();
}
if (this._mouseEntered) {
if (this._lastMouseMove.x != Input.mousePosition.x || this._lastMouseMove.y != Input.mousePosition.y) {
this.handleMouseMovement();
}
}
this._lastMouseMove = Input.mousePosition;
if (this._mouseEntered) {
this.handleMouseScroll();
}
D.assert(this._windowAdapter != null);
this._windowAdapter.Update();
this._windowAdapter.OnGUI(_repaintEvent);
}
void OnGUI() {
this._displayMetrics.OnGUI();
if (Event.current.type == EventType.KeyDown || Event.current.type == EventType.KeyUp) {
this._windowAdapter.OnGUI(Event.current);
}
}
void handleMouseMovement() {
var pos = this.getPointPosition(Input.mousePosition);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: PointerDeviceKind.mouse,
device: this.getMouseButtonDown(),
physicalX: pos.x,
physicalY: pos.y
));
}
void handleMouseScroll() {
if (Input.mouseScrollDelta.y != 0 || Input.mouseScrollDelta.x != 0) {
var scaleFactor = this.canvas.scaleFactor;
var pos = this.getPointPosition(Input.mousePosition);
this._scrollInput.onScroll(Input.mouseScrollDelta.x * scaleFactor,
Input.mouseScrollDelta.y * scaleFactor,
pos.x,
pos.y,
InputUtils.getScrollButtonKey());
}
var deltaScroll = this._scrollInput.getScrollDelta();
if (deltaScroll != Vector2.zero) {
this._windowAdapter.postPointerEvent(new ScrollData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.scroll,
kind: PointerDeviceKind.mouse,
device: this._scrollInput.getDeviceId(),
physicalX: this._scrollInput.getPointerPosX(),
physicalY: this._scrollInput.getPointerPosY(),
scrollX: deltaScroll.x,
scrollY: deltaScroll.y
));
}
}
int getMouseButtonDown() {
for (int key = 0; key < mouseButtonNum; key++) {
if (Input.GetMouseButton(key)) {
return InputUtils.getMouseButtonKey(key);
}
}
return 0;
}
public void OnPointerDown(PointerEventData eventData) {
EventSystem.current.SetSelectedGameObject(this.gameObject, eventData);
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.down,
kind: InputUtils.getPointerDeviceKind(eventData),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.x,
physicalY: position.y
));
}
public void OnPointerUp(PointerEventData eventData) {
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.up,
kind: InputUtils.getPointerDeviceKind(eventData),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.x,
physicalY: position.y
));
}
public Vector2 getPointPosition(PointerEventData eventData) {
Vector2 localPoint;
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rectTransform, eventData.position,
eventData.enterEventCamera, out localPoint);
var scaleFactor = this.canvas.scaleFactor;
localPoint.x = (localPoint.x - this.rectTransform.rect.min.x) * scaleFactor;
localPoint.y = (this.rectTransform.rect.max.y - localPoint.y) * scaleFactor;
return localPoint;
}
public Vector2 getPointPosition(Vector2 position) {
Vector2 localPoint;
Camera eventCamera = null;
if (this.canvas.renderMode != RenderMode.ScreenSpaceCamera) {
eventCamera = this.canvas.GetComponent<GraphicRaycaster>().eventCamera;
}
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rectTransform, position,
eventCamera, out localPoint);
var scaleFactor = this.canvas.scaleFactor;
localPoint.x = (localPoint.x - this.rectTransform.rect.min.x) * scaleFactor;
localPoint.y = (this.rectTransform.rect.max.y - localPoint.y) * scaleFactor;
return localPoint;
}
public void OnDrag(PointerEventData eventData) {
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.move,
kind: InputUtils.getPointerDeviceKind(eventData),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.x,
physicalY: position.y
));
}
public void OnPointerEnter(PointerEventData eventData) {
var pointerKey = InputUtils.getPointerDeviceKey(eventData);
this._enteredPointers.Add(pointerKey);
this._lastMouseMove = eventData.position;
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: InputUtils.getPointerDeviceKind(eventData),
device: pointerKey,
physicalX: position.x,
physicalY: position.y
));
}
public void OnPointerExit(PointerEventData eventData) {
var pointerKey = InputUtils.getPointerDeviceKey(eventData);
this._enteredPointers.Remove(pointerKey);
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: InputUtils.getPointerDeviceKind(eventData),
device: pointerKey,
physicalX: position.x,
physicalY: position.y
));
}
void unfocusIfNeeded() {
using (this._windowAdapter.getScope()) {
var focusNode = WidgetsBinding.instance.focusManager.currentFocus;
if (focusNode != null) {
focusNode.unfocus();
}
}
}
}
}

6
Samples/ReduxSample/ReduxSample.asmdef


{
"name": "ReduxSample",
"references": ["Unity.UIWidgets"],
"includePlatforms": [],
"excludePlatforms": []
}

7
Samples/ReduxSample/ReduxSample.asmdef.meta


fileFormatVersion: 2
guid: da9b62bed239142ed9912e3274b2aa14
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

6
Samples/UIWidgetSample/UIWidgetSample.asmdef


{
"name": "UIWidgetSample",
"references": ["Unity.UIWidgets"],
"includePlatforms": [],
"excludePlatforms": []
}

7
Samples/UIWidgetSample/UIWidgetSample.asmdef.meta


fileFormatVersion: 2
guid: f461a1d3753154b95a03ee91cfcbbbb7
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

27
Samples/UIWidgetSample/PageViewCanvas.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace UIWidgetsSample {
public class PageViewCanvas : WidgetCanvas {
protected override Widget getWidget() {
return new Container(
width: 200,
height: 400,
child: new PageView(
children: new List<Widget>() {
new Container(
color: new Color(0xFFE91E63)
),
new Container(
color: new Color(0xFF00BCD4)
),
new Container(
color: new Color(0xFF673AB7)
)
}
));
}
}
}

42
Samples/UIWidgetSample/ScrollbarCanvas.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace UIWidgetsSample {
public class ScrollbarCanvas : WidgetCanvas {
protected override Widget getWidget() {
return new Container(
decoration: new BoxDecoration(
border: Border.all(color: new Color(0xFFFFFF00))
),
child: new Scrollbar(
child: new ListView(
children: new List<Widget> {
new Container(height: 40.0f, child: new Text("0")),
new Container(height: 40.0f, child: new Text("1")),
new Container(height: 40.0f, child: new Text("2")),
new Container(height: 40.0f, child: new Text("3")),
new Container(height: 40.0f, child: new Text("4")),
new Container(height: 40.0f, child: new Text("5")),
new Container(height: 40.0f, child: new Text("6")),
new Container(height: 40.0f, child: new Text("7")),
new Container(height: 40.0f, child: new Text("8")),
new Container(height: 40.0f, child: new Text("9")),
new Container(height: 40.0f, child: new Text("10")),
new Container(height: 40.0f, child: new Text("11")),
new Container(height: 40.0f, child: new Text("12")),
new Container(height: 40.0f, child: new Text("13")),
new Container(height: 40.0f, child: new Text("14")),
new Container(height: 40.0f, child: new Text("15")),
new Container(height: 40.0f, child: new Text("16")),
new Container(height: 40.0f, child: new Text("17")),
}
)
)
);
}
}
}

/Runtime/engine/WidgetCanvas.cs.meta → /Runtime/engine/UIWidgetsPanel.cs.meta

/Samples/MaterialSample/DividerButtonCanvas.cs.meta → /Samples/MaterialSample/DividerButton.cs.meta

/Samples/MaterialSample/DividerButtonCanvas.cs → /Samples/MaterialSample/DividerButton.cs

/Samples/ReduxSample/CounterApp/CounterAppCanvas.cs.meta → /Samples/ReduxSample/CounterApp/CounterAppSample.cs.meta

/Samples/ReduxSample/CounterApp/CounterAppCanvas.cs → /Samples/ReduxSample/CounterApp/CounterAppSample.cs

/Samples/UIWidgetSample/AsScreenCanvas.cs.meta → /Samples/UIWidgetSample/AsScreenSample.cs.meta

/Samples/UIWidgetSample/CustomPaintCanvas.cs.meta → /Samples/UIWidgetSample/CustomPaintSample.cs.meta

/Samples/UIWidgetSample/DragDropCanvas.cs.meta → /Samples/UIWidgetSample/DragDropSample.cs.meta

/Samples/UIWidgetSample/ExpansionPanelCanvas.cs.meta → /Samples/UIWidgetSample/ExpansionPanelSample.cs.meta

/Samples/UIWidgetSample/MaterialCanvas.cs.meta → /Samples/UIWidgetSample/MaterialSample.cs.meta

/Samples/UIWidgetSample/NavigationCanvas.cs.meta → /Samples/UIWidgetSample/NavigationSample.cs.meta

/Samples/UIWidgetSample/PageViewCanvas.cs.meta → /Samples/UIWidgetSample/PageViewSample.cs.meta

/Samples/UIWidgetSample/ScrollbarCanvas.cs.meta → /Samples/UIWidgetSample/ScrollbarSample.cs.meta

/Samples/UIWidgetSample/TextInputCanvas.cs.meta → /Samples/UIWidgetSample/TextInputSample.cs.meta

/Samples/UIWidgetSample/ToDoAppCanvas.cs.meta → /Samples/UIWidgetSample/ToDoAppSample.cs.meta

/Samples/UIWidgetSample/AsScreenCanvas.cs → /Samples/UIWidgetSample/AsScreenSample.cs

/Samples/UIWidgetSample/CustomPaintCanvas.cs → /Samples/UIWidgetSample/CustomPaintSample.cs

/Samples/UIWidgetSample/DragDropCanvas.cs → /Samples/UIWidgetSample/DragDropSample.cs

/Samples/UIWidgetSample/ExpansionPanelCanvas.cs → /Samples/UIWidgetSample/ExpansionPanelSample.cs

/Samples/UIWidgetSample/MaterialCanvas.cs → /Samples/UIWidgetSample/MaterialSample.cs

/Samples/UIWidgetSample/NavigationCanvas.cs → /Samples/UIWidgetSample/NavigationSample.cs

/Samples/UIWidgetSample/TextInputCanvas.cs → /Samples/UIWidgetSample/TextInputSample.cs

/Samples/UIWidgetSample/ToDoAppCanvas.cs → /Samples/UIWidgetSample/ToDoAppSample.cs

正在加载...
取消
保存