浏览代码

Merge branches 'kgdev' and 'master' of gitlab.cds.internal.unity3d.com:upm-packages/ui-widgets/com.unity.uiwidgets into kgdev

# Conflicts:
#	Runtime/ui/painting/canvas.cs
#	Runtime/ui/painting/canvas_impl.cs
/main
kg 6 年前
当前提交
781f06bb
共有 82 个文件被更改,包括 892 次插入730 次删除
  1. 25
      README.md
  2. 8
      Runtime/debugger/inspector_treeview.cs
  3. 4
      Runtime/debugger/inspector_window.cs
  4. 6
      Runtime/editor/editor_window.cs
  5. 42
      Runtime/engine/input_utils.cs
  6. 8
      Runtime/ui/painting/canvas.cs
  7. 34
      Runtime/ui/painting/canvas_impl.cs
  8. 12
      Runtime/ui/painting/canvas_shader.cs
  9. 2
      Runtime/ui/painting/tessellation_generator.cs
  10. 57
      Runtime/ui/painting/txt/mesh_generator.cs
  11. 17
      Runtime/ui/txt/linebreaker.cs
  12. 14
      Runtime/ui/txt/word_separate.cs
  13. 30
      Runtime/ui/txt/wordbreaker.cs
  14. 4
      Runtime/widgets/app.cs
  15. 12
      Runtime/widgets/basic.cs
  16. 2
      Runtime/widgets/binding.cs
  17. 45
      Runtime/widgets/transitions.cs
  18. 11
      Samples/MaterialSample/DividerButton.cs
  19. 10
      Samples/ReduxSample/CounterApp/CounterApp.unity
  20. 8
      Samples/ReduxSample/CounterApp/CounterAppSample.cs
  21. 10
      Samples/ReduxSample/ObjectFinder/ObjectFinderApp.cs
  22. 14
      Samples/UIWidgetSample/UIWidgetSample.unity
  23. 13
      Samples/UIWidgetSample/ToDoAppSample.cs
  24. 33
      Samples/UIWidgetSample/TextInputSample.cs
  25. 24
      Samples/UIWidgetSample/NavigationSample.cs
  26. 10
      Samples/UIWidgetSample/MaterialSample.cs
  27. 10
      Samples/UIWidgetSample/ExpansionPanelSample.cs
  28. 28
      Samples/UIWidgetSample/DragDropSample.cs
  29. 15
      Samples/UIWidgetSample/CustomPaintSample.cs
  30. 55
      Samples/UIWidgetSample/AsScreenSample.cs
  31. 12
      Tests/Editor/CanvasAndLayers.cs
  32. 2
      Tests/Editor/EditableTextWiget.cs
  33. 2
      Tests/Editor/Widgets.cs
  34. 4
      Editor/UIWidgetsPanelEditor.cs
  35. 9
      Runtime/editor/editor_utils.cs
  36. 328
      Runtime/engine/UIWidgetsPanel.cs
  37. 29
      Samples/UIWidgetSample/PageViewSample.cs
  38. 44
      Samples/UIWidgetSample/ScrollbarSample.cs
  39. 20
      Samples/UIWidgetSample/UIWidgetsSamplePanel.cs
  40. 11
      Samples/UIWidgetSample/UIWidgetsSamplePanel.cs.meta
  41. 45
      Samples/UIWidgetSample/Utils.cs
  42. 11
      Samples/UIWidgetSample/Utils.cs.meta
  43. 14
      Samples/UIWidgetsSample.asmdef
  44. 7
      Samples/UIWidgetsSample.asmdef.meta
  45. 27
      Editor/EditorExample.cs
  46. 11
      Editor/EditorExample.cs.meta
  47. 8
      Editor/editor.meta
  48. 380
      Runtime/engine/WidgetCanvas.cs
  49. 6
      Samples/ReduxSample/ReduxSample.asmdef
  50. 7
      Samples/ReduxSample/ReduxSample.asmdef.meta
  51. 6
      Samples/UIWidgetSample/UIWidgetSample.asmdef
  52. 7
      Samples/UIWidgetSample/UIWidgetSample.asmdef.meta
  53. 27
      Samples/UIWidgetSample/PageViewCanvas.cs
  54. 42
      Samples/UIWidgetSample/ScrollbarCanvas.cs
  55. 0
      /Runtime/engine/UIWidgetsPanel.cs.meta
  56. 0
      /Samples/MaterialSample/DividerButton.cs.meta
  57. 0
      /Samples/MaterialSample/DividerButton.cs
  58. 0
      /Samples/ReduxSample/CounterApp/CounterAppSample.cs.meta
  59. 0
      /Samples/ReduxSample/CounterApp/CounterAppSample.cs
  60. 0
      /Samples/UIWidgetSample/ToDoAppSample.cs.meta
  61. 0
      /Samples/UIWidgetSample/ToDoAppSample.cs
  62. 0
      /Samples/UIWidgetSample/TextInputSample.cs.meta
  63. 0
      /Samples/UIWidgetSample/TextInputSample.cs
  64. 0
      /Samples/UIWidgetSample/ScrollbarSample.cs.meta
  65. 0
      /Samples/UIWidgetSample/PageViewSample.cs.meta
  66. 0
      /Samples/UIWidgetSample/NavigationSample.cs.meta
  67. 0
      /Samples/UIWidgetSample/NavigationSample.cs
  68. 0
      /Samples/UIWidgetSample/MaterialSample.cs.meta
  69. 0
      /Samples/UIWidgetSample/MaterialSample.cs
  70. 0
      /Samples/UIWidgetSample/ExpansionPanelSample.cs.meta
  71. 0
      /Samples/UIWidgetSample/ExpansionPanelSample.cs
  72. 0
      /Samples/UIWidgetSample/DragDropSample.cs.meta
  73. 0
      /Samples/UIWidgetSample/DragDropSample.cs
  74. 0
      /Samples/UIWidgetSample/CustomPaintSample.cs.meta
  75. 0
      /Samples/UIWidgetSample/CustomPaintSample.cs
  76. 0
      /Samples/UIWidgetSample/AsScreenSample.cs.meta
  77. 0
      /Samples/UIWidgetSample/AsScreenSample.cs
  78. 0
      /Editor/UIWidgetsPanelEditor.cs
  79. 0
      /Runtime/editor/editor_utils.cs
  80. 0
      /Runtime/editor/editor_utils.cs.meta
  81. 0
      /Editor/UIWidgetsPanelEditor.cs.meta

25
README.md


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: (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++;
});
},

8
Runtime/debugger/inspector_treeview.cs


public override string displayName {
get { return this.node.name + this.node.description; }
get {
if (this.node.showName && !string.IsNullOrEmpty(this.node.name)) {
return $"{this.node.name}{this.node.separator} {this.node.description}";
}
return this.node.description;
}
}
}

4
Runtime/debugger/inspector_window.cs


window.Show();
}
void OnEnable() {
this.titleContent = new GUIContent("UIWidgets Inspector");
}
void OnGUI() {
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
this.DoSelectDropDown();

6
Runtime/editor/editor_window.cs


this._binding.attachRootWidget(root);
}
}
public void attachRootWidget(Func<Widget> root) {
using (this.getScope()) {
this._binding.attachRootWidget(root());
}
}
public override TextInput textInput {
get { return this._textInput; }

42
Runtime/engine/input_utils.cs


using Unity.UIWidgets.foundation;
public static class InputUtils {
static class InputUtils {
const int preservedPointerKeyNum = 10;
const int preservedKeyNum = 10;
const int preservedMouseKeyNum = 100;
const int fingerKeyStart = preservedKeyNum + preservedMouseKeyNum;
public static PointerDeviceKind getPointerDeviceKind() {
#if UNITY_IOS || UNITY_ANDROID
return PointerDeviceKind.touch;
#else
return PointerDeviceKind.mouse;
#endif
public static PointerDeviceKind getPointerDeviceKind(PointerEventData eventData) {
return isTouchEvent(eventData) ? PointerDeviceKind.touch : PointerDeviceKind.mouse;
#if UNITY_IOS || UNITY_ANDROID
return getTouchFingerKey(eventData.pointerId);
#else
return getMouseButtonKey((int) eventData.button);
#endif
return isTouchEvent(eventData)
? getTouchFingerKey(eventData.pointerId)
: getMouseButtonKey((int) eventData.button);
}
public static int getScrollButtonKey() {

public static int getMouseButtonKey(int buttonId) {
return buttonId + preservedPointerKeyNum;
D.assert(buttonId < preservedMouseKeyNum);
return buttonId + preservedKeyNum;
}
static int getTouchFingerKey(int fingerId) {
return fingerId + fingerKeyStart;
}
static bool isTouchEvent(PointerEventData eventData) {
//pointerId >= 0 : touches
//ref: https://docs.unity3d.com/ScriptReference/EventSystems.PointerEventData-pointerId.html
return eventData.pointerId >= 0;
public static int getTouchFingerKey(int fingerId) {
return fingerId + preservedPointerKeyNum;
static bool isMouseEvent(PointerEventData eventData) {
//pointerId = -1, -2, -3 : mouse buttons
//ref: https://docs.unity3d.com/ScriptReference/EventSystems.PointerEventData-pointerId.html
return eventData.pointerId < 0;
}
}
}

8
Runtime/ui/painting/canvas.cs


using System;
using UnityEngine;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.ui {
public interface Canvas {

void drawTextBlob(TextBlob textBlob, Offset offset, Paint paint);
void drawParagraph(Paragraph paragraph, Offset offset);
void flush();
void reset();

offset = offset,
paint = new Paint(paint),
});
}
public void drawParagraph(Paragraph paragraph, Offset offset) {
D.assert(paragraph != null);
D.assert(PaintingUtils._offsetIsValid(offset));
paragraph.paint(this, offset);
}
public virtual void flush() {

34
Runtime/ui/painting/canvas_impl.cs


var matrix = new Matrix3(state.matrix);
matrix.preTranslate(offset.dx, offset.dy);
var mesh = MeshGenerator.generateMesh(textBlob, scale)?.transform(matrix);
if (mesh == null) {
return;
}
var mesh = new TextBlobMesh(textBlob, scale, matrix);
// request font texture so text mesh could be generated correctly
var style = textBlob.style;
var fontSizeToLoad = Mathf.CeilToInt(style.UnityFontSize * scale);
var subText = textBlob.text.Substring(textBlob.textOffset, textBlob.textSize);
font.RequestCharactersInTexture(subText, fontSizeToLoad, style.UnityFontStyle);
if (!this._applyClip(mesh.bounds)) {
if (!this._applyClip(textBlob.bounds)) {
return;
}

if (paint.maskFilter != null && paint.maskFilter.sigma != 0) {
this._drawWithMaskFilter(mesh.bounds, drawMesh, paint, paint.maskFilter);
this._drawWithMaskFilter(textBlob.bounds, drawMesh, paint, paint.maskFilter);
return;
}

public void flush(Picture picture) {
this._reset();
this._drawPicture(picture, false);
D.assert(this._layers.Count == 1);

// clear triangles first in order to bypass validation in SetVertices.
cmd.meshObj.SetTriangles((int[]) null, 0, false);
D.assert(cmd.mesh.vertices.Count > 0);
cmd.meshObj.SetVertices(cmd.mesh.vertices);
cmd.meshObj.SetTriangles(cmd.mesh.triangles, 0, false);
cmd.meshObj.SetUVs(0, cmd.mesh.uv);
MeshMesh mesh = cmd.mesh;
if (cmd.textMesh != null) {
mesh = cmd.textMesh.resovleMesh();
}
D.assert(mesh.vertices.Count > 0);
cmd.meshObj.SetVertices(mesh.vertices);
cmd.meshObj.SetTriangles(mesh.triangles, 0, false);
cmd.meshObj.SetUVs(0, mesh.uv);
if (cmd.mesh.matrix == null) {
if (mesh.matrix == null) {
cmd.properties.SetFloatArray(RenderDraw.matId, cmd.mesh.matrix.fMat);
cmd.properties.SetFloatArray(RenderDraw.matId, mesh.matrix.fMat);
}
cmdBuf.DrawMesh(cmd.meshObj, RenderDraw.idMat, cmd.material, 0, cmd.pass, cmd.properties);

internal class RenderDraw {
public MeshMesh mesh;
public TextBlobMesh textMesh;
public int pass;
public MaterialPropertyBlock properties;
public RenderLayer layer;

12
Runtime/ui/painting/canvas_shader.cs


public static PictureFlusher.RenderDraw texAlpha(PictureFlusher.RenderLayer layer, Paint paint,
MeshMesh mesh, Texture tex) {
return texAlpha(layer, paint, mesh, null, tex);
}
public static PictureFlusher.RenderDraw texAlpha(PictureFlusher.RenderLayer layer, Paint paint,
TextBlobMesh textMesh, Texture tex) {
return texAlpha(layer, paint, null, textMesh, tex);
}
public static PictureFlusher.RenderDraw texAlpha(PictureFlusher.RenderLayer layer, Paint paint,
MeshMesh mesh, TextBlobMesh textMesh, Texture tex) {
var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);
_getShaderPassAndProps(layer, paint, mesh, 1.0f, out var pass, out var props);
tex.filterMode = paint.filterMode;

return new PictureFlusher.RenderDraw {
mesh = mesh,
textMesh = textMesh,
pass = pass,
material = mat,
properties = props,

2
Runtime/ui/painting/tessellation_generator.cs


}
public void touch(long timeTolive = 5) {
this._timeToLive = timeTolive + MeshGenerator.frameCount;
this._timeToLive = timeTolive + TextBlobMesh.frameCount;
}
}

57
Runtime/ui/painting/txt/mesh_generator.cs


}
public void touch(long timeTolive = 5) {
this._timeToLive = timeTolive + MeshGenerator.frameCount;
this._timeToLive = timeTolive + TextBlobMesh.frameCount;
static class MeshGenerator {
class TextBlobMesh {
readonly TextBlob _textBlob;
readonly float _scale;
readonly Matrix3 _transform;
MeshMesh _mesh;
bool _resolved;
public TextBlobMesh(TextBlob textBlob, float scale, Matrix3 transform) {
this._textBlob = textBlob;
this._scale = scale;
this._transform = transform;
}
public static long frameCount {
get { return _frameCount; }
}

}
}
public static MeshMesh generateMesh(TextBlob textBlob, float scale) {
var style = textBlob.style;
public MeshMesh resovleMesh() {
if (this._resolved) {
return this._mesh;
}
this._resolved = true;
var style = this._textBlob.style;
var key = new MeshKey(textBlob.instanceId, scale);
var key = new MeshKey(this._textBlob.instanceId, this._scale);
return meshInfo.mesh;
this._mesh = meshInfo.mesh.transform(this._transform);
return this._mesh;
var length = textBlob.textSize;
var text = textBlob.text;
var fontSizeToLoad = Mathf.CeilToInt(style.UnityFontSize * scale);
var subText = textBlob.text.Substring(textBlob.textOffset, textBlob.textSize);
font.RequestCharactersInTexture(subText, fontSizeToLoad, style.UnityFontStyle);
var length = this._textBlob.textSize;
var text = this._textBlob.text;
var fontSizeToLoad = Mathf.CeilToInt(style.UnityFontSize * this._scale);
var ch = text[charIndex + textBlob.textOffset];
var ch = text[charIndex + this._textBlob.textOffset];
var position = textBlob.positions[charIndex];
var position = this._textBlob.positions[charIndex];
if (LayoutUtils.isWordSpace(ch) || LayoutUtils.isLineEndSpace(ch) || ch == '\t') {
continue;
}

var minX = charInfo.minX / scale;
var maxX = charInfo.maxX / scale;
var minY = charInfo.minY / scale;
var maxY = charInfo.maxY / scale;
var minX = charInfo.minX / this._scale;
var maxX = charInfo.maxX / this._scale;
var minY = charInfo.minY / this._scale;
var maxY = charInfo.maxY / this._scale;
var baseIndex = vertices.Count;

MeshMesh mesh = vertices.Count > 0 ? new MeshMesh(null, vertices, triangles, uv) : null;
_meshes[key] = new MeshInfo(key, mesh, fontInfo.textureVersion);
return mesh;
this._mesh = mesh.transform(this._transform);
return this._mesh;
}
}
}

17
Runtime/ui/txt/linebreaker.cs


int candIndex = this._candidates.Count;
this._candidates.Add(cand);
if (cand.postBreak - this._preBreak > this._lineWidth) {
if (this._bestBreak == this._lastBreak) {
this._bestBreak = candIndex;
}
this._pushGreedyBreak();
}
while (this._lastBreak != candIndex && cand.postBreak - this._preBreak > this._lineWidth) {
for (int i = this._lastBreak + 1; i < candIndex; i++) {
float penalty = this._candidates[i].penalty;
if (penalty <= this._bestScore) {
this._bestBreak = i;
this._bestScore = penalty;
}
}
if (this._bestBreak == this._lastBreak) {
this._bestBreak = candIndex;
}
this._pushGreedyBreak();
}

14
Runtime/ui/txt/word_separate.cs


Backward,
}
enum characterType {
internal enum characterType {
LetterLike,
Symbol,
WhiteSpace

return new Range<int>(0, 0);
}
var t = this.classifyChar(index);
var t = classifyChar(this._text, index);
if (this.classifyChar(i) != t) {
if (classifyChar(this._text, i) != t) {
break;
}

int end = index;
for (int i = index; i < this._text.Length; ++i) {
if (!char.IsLowSurrogate(this._text[i])) {
if (this.classifyChar(i) != t) {
if (classifyChar(this._text, i) != t) {
break;
}

}
characterType classifyChar(int index) {
if (char.IsWhiteSpace(this._text, index)) {
internal static characterType classifyChar(string text, int index) {
if (char.IsWhiteSpace(text, index)) {
if (char.IsLetterOrDigit(this._text, index) || this._text[index] == '\'') {
if (char.IsLetterOrDigit(text, index) || text[index] == '\'') {
return characterType.LetterLike;
}

30
Runtime/ui/txt/wordbreaker.cs


namespace Unity.UIWidgets.ui {
public class WordBreaker {
public const uint U16_SURROGATE_OFFSET = ((0xd800 << 10) + 0xdc00 - 0x10000);

this._current = this._findNextBreakInEmailOrUrl();
}
else {
this._current = this._findNextBreakNormal();
this._current = this._findNextBoundaryNormal();
}
return this._current;

this._current = 0;
this._scanOffset = 0;
this._inEmailOrUrl = false;
this.nextUntilCodePoint();
}
public int current() {

return 0;
}
int _findNextBreakNormal() {
int _findNextBoundaryNormal() {
WordSeparate.characterType preType = WordSeparate.classifyChar(this._text, this._current + this._offset);
char c = this._text[this._current + this._offset];
if (LayoutUtils.isWordSpace(c) || c == '\t') {
return this._current;
this.nextUntilCodePoint();
if (this._current >= this._size) {
break;
var currentType = WordSeparate.classifyChar(this._text, this._current + this._offset);
if ((currentType == WordSeparate.characterType.WhiteSpace)
!= (preType == WordSeparate.characterType.WhiteSpace)) {
break;
}
preType = currentType;
void _detectEmailOrUrl() {
}

public static uint getSupplementary(uint lead, uint trail) {
return (char) (((uint) (lead) << 10) + (uint) (trail - U16_SURROGATE_OFFSET));
}
void nextUntilCodePoint() {
while (this._current < this._size
&& (char.IsLowSurrogate(this._text[this._current + this._offset])
|| char.IsHighSurrogate(this._text[this._current + this._offset]))) {
this._current++;
}
}
}
}

4
Runtime/widgets/app.cs


string initialRoute = null,
Dictionary<string, WidgetBuilder> routes = null,
TransitionBuilder builder = null,
Window window = null,
D.assert(window != null);
this.window = window;
this.window = Window.instance;
this.home = home;
this.navigatorKey = navigatorKey;
this.onGenerateRoute = onGenerateRoute;

12
Runtime/widgets/basic.cs


}
}
public class SliverToBoxAdapter : SingleChildRenderObjectWidget {
public SliverToBoxAdapter(
Key key = null,
Widget child = null) : base(key: key, child: child) {
}
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverToBoxAdapter();
}
}
public class Flex : MultiChildRenderObjectWidget {
public Flex(
Axis direction = Axis.vertical,

2
Runtime/widgets/binding.cs


Window.instance.onLocaleChanged += this.handleLocaleChanged;
this.widgetInspectorService = new WidgetInspectorService(this);
this.addPersistentFrameCallback((duration) => {
MeshGenerator.tickNextFrame();
TextBlobMesh.tickNextFrame();
TessellationGenerator.tickNextFrame();
});
}

45
Runtime/widgets/transitions.cs


}
}
public class SizeTransition : AnimatedWidget {
public SizeTransition(
Key key = null,
Axis axis = Axis.vertical,
Animation<float> sizeFactor = null,
float axisAlignment = 0.0f,
Widget child = null) : base(key: key, listenable: sizeFactor) {
D.assert(axis != null);
D.assert(sizeFactor != null);
D.assert(axisAlignment != null);
this.axis = axis;
this.axisAlignment = axisAlignment;
this.child = child;
}
public readonly Axis axis;
public readonly float axisAlignment;
Animation<float> sizeFactor {
get { return (Animation<float>) this.listenable; }
}
public readonly Widget child;
protected internal override Widget build(BuildContext context) {
Alignment alignment;
if (this.axis == Axis.vertical) {
alignment = new Alignment(-1.0f, this.axisAlignment);
}
else {
alignment = new Alignment(this.axisAlignment, -1.0f);
}
return new ClipRect(
child: new Align(
alignment: alignment,
widthFactor: this.axis == Axis.horizontal ? (float?) Mathf.Max(this.sizeFactor.value, 0.0f) : null,
heightFactor: this.axis == Axis.vertical ? (float?) Mathf.Max(this.sizeFactor.value, 0.0f) : null,
child: this.child
)
);
}
}
public class FadeTransition : SingleChildRenderObjectWidget {
public FadeTransition(Key key = null, Animation<float> opacity = null,
Widget child = null) : base(key: key, child: child) {

11
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() {
return new WidgetsApp(
home: new DemoApp(),
pageRouteBuilder: this.pageRouteBuilder);
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

8
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() {
return new WidgetsApp(
home: new CounterApp(),
pageRouteBuilder: this.pageRouteBuilder);
}
}

10
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() {
return new WidgetsApp(
home: new StoreProvider<FinderAppState>(StoreProvider.store, this.createRootWidget()),
pageRouteBuilder: this.pageRouteBuilder);
Widget createWidget() {
Widget createRootWidget() {
return new StoreConnector<FinderAppState, ObjectFinderAppWidgetModel>(
(context, viewModel) => new ObjectFinderAppWidget(
viewModel, this.gameObject.name

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

13
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() {
return new WidgetsApp(
home: new ToDoListApp(),
pageRouteBuilder: this.pageRouteBuilder);
}
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;
}

33
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() {
return new WidgetsApp(
home: new EditableInputTypeWidget(),
pageRouteBuilder: this.pageRouteBuilder);
class _TextInputSampleState : State<TextInputSample> {
class _TextInputSampleState : State<_TextInputSample> {
TextEditingController titleController = new TextEditingController("");
TextEditingController descController = new TextEditingController("");
FocusNode _titleFocusNode;

List<Widget> widgets = new List<Widget>();
var style = new TextStyle();
var cursorColor = new Color(0xFF000000);
var selectionColor = new Color(0xFF6F6F6F);
new EditableText(controller, node, style, cursorColor, onSubmitted: this.textSubmitted)))));
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, onSubmitted: this.textSubmitted)))));
new EditableText(controller, node, style, cursorColor, maxLines: 4,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, maxLines: 4,
new EditableText(controller, node, style, cursorColor, obscureText: true,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, obscureText: true,
new EditableText(controller, node, style, cursorColor, keyboardType: TextInputType.number,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.number,
new EditableText(controller, node, style, cursorColor, keyboardType: TextInputType.phone,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.phone,
new EditableText(controller, node, style, cursorColor, keyboardType: TextInputType.emailAddress,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.emailAddress,
new EditableText(controller, node, style, cursorColor, keyboardType: TextInputType.url,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.url,
onSubmitted: this.textSubmitted)))));
return new Column(

24
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() {
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); }
});
protected override PageRouteFactory pageRouteBuilder {
get {
return (RouteSettings settings, WidgetBuilder builder) =>

10
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() {
return new WidgetsApp(
home: this.testCases[this.testCaseId],
pageRouteBuilder: this.pageRouteBuilder);
}
}

10
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() {
return new WidgetsApp(
home: this.testCases[this.testCaseId],
pageRouteBuilder: this.pageRouteBuilder);
}
}

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"))
)
)

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() {
return new WidgetsApp(
home: new DragDropApp(),
pageRouteBuilder: this.pageRouteBuilder
);
}
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
)

15
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() {
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);
}
}

55
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() {
return new WidgetsApp(
home: new AsScreenWidget(),
pageRouteBuilder: this.pageRouteBuilder);
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);
}
}
}

12
Tests/Editor/CanvasAndLayers.cs


this.clipRRect,
this.saveLayer,
this.drawLine,
this.drawParagraph,
};
this._optionStrings = this._options.Select(x => x.Method.Name).ToArray();
this._selected = 0;

editorCanvas.flush();
}
void drawParagraph() {
var pb = new ParagraphBuilder(new ParagraphStyle{});
pb.addText("Hello drawParagraph");
var paragraph = pb.build();
paragraph.layout(new ParagraphConstraints(width:300));
var canvas = new CommandBufferCanvas(this._renderTexture, Window.instance.devicePixelRatio,
this._meshPool);
canvas.drawParagraph(paragraph, new Offset(10f, 100f));
canvas.flush();
}
void drawImageRect() {
if (this._stream == null || this._stream.completer == null || this._stream.completer.currentImage == null) {
return;

2
Tests/Editor/EditableTextWiget.cs


cursorColor: Color.fromARGB(255, 0, 0, 0)
)
);
this.windowAdapter.attachRootWidget(new WidgetsApp(window: this.windowAdapter, home: this.root,
this.windowAdapter.attachRootWidget(() => new WidgetsApp(home: this.root,
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(
settings: settings,

2
Tests/Editor/Widgets.cs


}
void _attachRootWidget(Widget widget) {
this.windowAdapter.attachRootWidget(new WidgetsApp(window: this.windowAdapter, home: widget,
this.windowAdapter.attachRootWidget(() => new WidgetsApp(home: widget,
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(
settings: settings,

4
Editor/UIWidgetsPanelEditor.cs


using UnityEditor.UI;
namespace Unity.UIWidgets.Editor {
[CustomEditor(typeof(WidgetCanvas), true)]
[CustomEditor(typeof(UIWidgetsPanel), true)]
public class WidgetCanvasEditor : RawImageEditor {
public class UIWidgetsPanelEditor : RawImageEditor {
public override void OnInspectorGUI() {
base.OnInspectorGUI();
var pixelRatioProperty = this.serializedObject.FindProperty("devicePixelRatioOverride");

9
Runtime/editor/editor_utils.cs


#if UNITY_EDITOR
using UnityEditor;
using UnityEditor;
namespace Unity.UIWidgets.Editor {
[InitializeOnLoad]
public class EditorUtils {

return true;
}
}
}
}
#endif

328
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 = this._uiWidgetsPanel.rectTransform.rect;
var size = new Vector2(rect.width,rect.height) *
this._uiWidgetsPanel.canvas.scaleFactor / 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();
Widget root;
using (this._windowAdapter.getScope()) {
root = this.createWidget();
}
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 override void OnDisable() {
D.assert(this._windowAdapter != null);
this._windowAdapter.OnDisable();
this._windowAdapter = null;
base.OnDisable();
}
protected virtual Widget createWidget() {
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();
}
}
}
}
}

29
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() {
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);
}
}
}

44
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() {
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);
}
}
}

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:

14
Samples/UIWidgetsSample.asmdef


{
"name": "UIWidgetsSample",
"references": [
"Unity.UIWidgets"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

7
Samples/UIWidgetsSample.asmdef.meta


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

27
Editor/EditorExample.cs


// -----------------------------------------------------------------------------
//
// Use this editor example C# file to develop editor (non-runtime) code.
//
// -----------------------------------------------------------------------------
namespace Unity.UIWidgets.Editor {
/// <summary>
/// Provide a general description of the public class.
/// </summary>
/// <remarks>
/// Packages require XmlDoc documentation for ALL Package APIs.
/// https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/xml-documentation-comments
/// </remarks>
public class MyPublicEditorExampleClass {
/// <summary>
/// Provide a description of what this private method does.
/// </summary>
/// <param name="parameter1"> Description of parameter 1 </param>
/// <param name="parameter2"> Description of parameter 2 </param>
/// <param name="parameter3"> Description of parameter 3 </param>
/// <returns> Description of what the function returns </returns>
public int CountThingsAndDoStuff(int parameter1, int parameter2, bool parameter3) {
return parameter3 ? (parameter1 + parameter2) : (parameter1 - parameter2);
}
}
}

11
Editor/EditorExample.cs.meta


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

8
Editor/editor.meta


fileFormatVersion: 2
guid: c339d59e8c37a49fdb2a6365764259fd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

380
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;
bool _mouseEntered;
readonly ScrollInput _scrollInput = new ScrollInput();
DisplayMetrics _displayMetrics;
const int mouseButtonNum = 3;
protected override void OnEnable() {
base.OnEnable();
//Disable touch -> mouse event 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;
}
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 UNITY_IOS || UNITY_ANDROID
if (this._mouseEntered && Input.touchCount != 0) {
this.handleTouchMove();
}
#else
if (this._mouseEntered && (this._lastMouseMove.x != Input.mousePosition.x ||
this._lastMouseMove.y != Input.mousePosition.y)) {
this.handleMouseMove();
}
#endif
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 handleTouchMove() {
for (var touchIndex = 0; touchIndex < Input.touchCount; touchIndex++) {
var touchEvent = Input.GetTouch(touchIndex);
if (touchEvent.phase != TouchPhase.Moved) {
continue;
}
var pos = this.getPointPosition(touchEvent.position);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: PointerDeviceKind.touch,
device: InputUtils.getTouchFingerKey(touchEvent.fingerId),
physicalX: pos.x,
physicalY: pos.y
));
}
}
void handleMouseMove() {
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(),
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(),
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(),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.x,
physicalY: position.y
));
}
public void OnPointerEnter(PointerEventData eventData) {
this._mouseEntered = true;
this._lastMouseMove = eventData.position;
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: InputUtils.getPointerDeviceKind(),
device: InputUtils.getPointerDeviceKey(eventData),
physicalX: position.x,
physicalY: position.y
));
}
public void OnPointerExit(PointerEventData eventData) {
this._mouseEntered = false;
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: InputUtils.getPointerDeviceKind(),
device: InputUtils.getPointerDeviceKey(eventData),
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/ToDoAppCanvas.cs.meta → /Samples/UIWidgetSample/ToDoAppSample.cs.meta

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/Editor/editor/WidgetCanvasEditor.cs → /Editor/UIWidgetsPanelEditor.cs

/Editor/editor/EditorUtils.cs → /Runtime/editor/editor_utils.cs

/Editor/editor/EditorUtils.cs.meta → /Runtime/editor/editor_utils.cs.meta

/Editor/editor/WidgetCanvasEditor.cs.meta → /Editor/UIWidgetsPanelEditor.cs.meta

正在加载...
取消
保存