浏览代码

Merge pull request #56 from Unity-Technologies/dev_1.17.5

Dev 1.17.5
/siyaoH-1.17-PlatformMessage
GitHub 4 年前
当前提交
5506baf2
共有 84 个文件被更改,包括 4636 次插入965 次删除
  1. 5
      .gitignore
  2. 7
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs
  3. 4
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.unity
  4. 5
      com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs
  5. 2
      com.unity.uiwidgets/Runtime/async2/future.cs
  6. 4
      com.unity.uiwidgets/Runtime/async2/timer.cs
  7. 26
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  8. 32
      com.unity.uiwidgets/Runtime/external/SplayTree.cs
  9. 14
      com.unity.uiwidgets/Runtime/foundation/debug.cs
  10. 2
      com.unity.uiwidgets/Runtime/gestures/binding.cs
  11. 414
      com.unity.uiwidgets/Runtime/painting/alignment.cs
  12. 18
      com.unity.uiwidgets/Runtime/painting/beveled_rectangle_border.cs
  13. 46
      com.unity.uiwidgets/Runtime/painting/binding.cs
  14. 680
      com.unity.uiwidgets/Runtime/painting/border_radius.cs
  15. 26
      com.unity.uiwidgets/Runtime/painting/borders.cs
  16. 459
      com.unity.uiwidgets/Runtime/painting/box_border.cs
  17. 2
      com.unity.uiwidgets/Runtime/painting/box_decoration.cs
  18. 11
      com.unity.uiwidgets/Runtime/painting/circle_border.cs
  19. 276
      com.unity.uiwidgets/Runtime/painting/colors.cs
  20. 26
      com.unity.uiwidgets/Runtime/painting/continuous_rectangle_border.cs
  21. 4
      com.unity.uiwidgets/Runtime/painting/decoration.cs
  22. 69
      com.unity.uiwidgets/Runtime/painting/decoration_image.cs
  23. 42
      com.unity.uiwidgets/Runtime/painting/edge_insets.cs
  24. 10
      com.unity.uiwidgets/Runtime/painting/gradient.cs
  25. 233
      com.unity.uiwidgets/Runtime/painting/image_cache.cs
  26. 307
      com.unity.uiwidgets/Runtime/painting/image_provider.cs
  27. 66
      com.unity.uiwidgets/Runtime/painting/image_resolution.cs
  28. 198
      com.unity.uiwidgets/Runtime/painting/image_stream.cs
  29. 15
      com.unity.uiwidgets/Runtime/painting/inline_span.cs
  30. 220
      com.unity.uiwidgets/Runtime/painting/matrix_utils.cs
  31. 40
      com.unity.uiwidgets/Runtime/painting/rounded_rectangle_border.cs
  32. 9
      com.unity.uiwidgets/Runtime/painting/shape_decoration.cs
  33. 31
      com.unity.uiwidgets/Runtime/painting/stadium_border.cs
  34. 29
      com.unity.uiwidgets/Runtime/painting/strut_style.cs
  35. 34
      com.unity.uiwidgets/Runtime/painting/text_painter.cs
  36. 2
      com.unity.uiwidgets/Runtime/painting/text_span.cs
  37. 167
      com.unity.uiwidgets/Runtime/painting/text_style.cs
  38. 8
      com.unity.uiwidgets/Runtime/rendering/binding.cs
  39. 2
      com.unity.uiwidgets/Runtime/rendering/image.cs
  40. 2
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  41. 4
      com.unity.uiwidgets/Runtime/scheduler2/binding.cs
  42. 3
      com.unity.uiwidgets/Runtime/services/binding.cs
  43. 22
      com.unity.uiwidgets/Runtime/ui2/window.cs
  44. 1
      com.unity.uiwidgets/Runtime/widgets/app.cs
  45. 1
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  46. 9
      com.unity.uiwidgets/Runtime/widgets/binding.cs
  47. 5
      com.unity.uiwidgets/Runtime/widgets/container.cs
  48. 11
      com.unity.uiwidgets/Runtime/widgets/debug.cs
  49. 3
      com.unity.uiwidgets/Runtime/widgets/disposable_build_context.cs
  50. 3
      com.unity.uiwidgets/Runtime/widgets/framework.cs
  51. 183
      com.unity.uiwidgets/Runtime/widgets/image.cs
  52. 2
      com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
  53. 4
      com.unity.uiwidgets/Runtime/widgets/navigator.cs
  54. 3
      com.unity.uiwidgets/Runtime/widgets/pages.cs
  55. 3
      engine/.gitignore
  56. 2
      engine/Build.bee.cs
  57. 7
      engine/README.md
  58. 24
      engine/src/shell/platform/unity/uiwidgets_panel.cc
  59. 4
      engine/src/shell/platform/unity/uiwidgets_panel.h
  60. 36
      Samples/UIWidgetsSamples_2019_4/Assets/Scene/TextTest.unity
  61. 8
      Samples/UIWidgetsSamples_2019_4/Assets/Scene.meta
  62. 8
      Samples/UIWidgetsSamples_2019_4/Assets/Script.meta
  63. 22
      com.unity.uiwidgets/Runtime/engine2/native_console.cs
  64. 13
      com.unity.uiwidgets/Runtime/painting/image_decoder.cs
  65. 3
      com.unity.uiwidgets/Runtime/painting/image_decoder.cs.meta
  66. 22
      engine/src/shell/platform/unity/unity_console.cc
  67. 26
      engine/src/shell/platform/unity/unity_console.h
  68. 537
      Samples/UIWidgetsSamples_2019_4/Assets/Scene/CountTest.unity
  69. 7
      Samples/UIWidgetsSamples_2019_4/Assets/Scene/CountTest.unity.meta
  70. 537
      Samples/UIWidgetsSamples_2019_4/Assets/Scene/ImageTest.unity
  71. 7
      Samples/UIWidgetsSamples_2019_4/Assets/Scene/ImageTest.unity.meta
  72. 89
      Samples/UIWidgetsSamples_2019_4/Assets/Script/CountTest.cs
  73. 98
      Samples/UIWidgetsSamples_2019_4/Assets/Script/ImageTest.cs
  74. 3
      Samples/UIWidgetsSamples_2019_4/Assets/Script/ImageTest.cs.meta
  75. 163
      Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs
  76. 11
      Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs.meta
  77. 7
      Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/confetti.json.meta
  78. 163
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
  79. 0
      /Samples/UIWidgetsSamples_2019_4/Assets/Scene/TextTest.unity
  80. 0
      /Samples/UIWidgetsSamples_2019_4/Assets/Scene/TextTest.unity.meta
  81. 0
      /Samples/UIWidgetsSamples_2019_4/Assets/Script/CountTest.cs.meta

5
.gitignore


npm-debug.log
build.sh.meta
build.bat.meta
# uiwidgets
Samples/Assets/Plugins/**
engine/build/**
engine/third_party/skia

7
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs


using UnityEngine.UI;
using Text = Unity.UIWidgets.widgets.Text;
using ui_ = Unity.UIWidgets.widgets.ui_;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample
{

public override Widget build(BuildContext context)
{
return new Container(
color: Color.white,
color: Color.fromARGB(255, 255, 0, 0),
new Text($"count: {count}"),
new Text($"count: {count}", style: new TextStyle(color: Color.fromARGB(255, 0 ,0 ,255))),
new CupertinoButton(
onPressed: () =>
{

});
},
child: new Container(
color: Color.black,
color: Color.fromARGB(255,0 , 255, 0),
width: 100,
height: 40
)

4
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.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: 100, y: 100}
m_SizeDelta: {x: 500, y: 500}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1777874942
CanvasRenderer:

m_GameObject: {fileID: 1777874940}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb0c6b34bc87472499dccfb52a9bcbde, type: 3}
m_Script: {fileID: 11500000, guid: 0817e3443c80cb943a03dcf7b120bd2e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}

5
com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs


EditorGUILayout.PropertyField(pixelRatioProperty);
EditorGUILayout.PropertyField(antiAliasingProperty);
UIWidgetsPanel panel = (UIWidgetsPanel)target;
if (GUILayout.Button("Take Screenshot")) {
panel.TakeScreenshot();
}
serializedObject.ApplyModifiedProperties();
}
}

2
com.unity.uiwidgets/Runtime/async2/future.cs


future.then((object value) => {
remaining--;
if (values != null) {
values[pos] = (T) value;
values.Insert(pos, (T)value);
if (remaining == 0) {
result._completeWithValue(values);
}

4
com.unity.uiwidgets/Runtime/async2/timer.cs


}
}
const long MILLI_TO_NANO = 1000000L;
UIMonoState_postTaskForTime(_postTaskForTime, (IntPtr) callabackHandle, _wakeupTime * 1000L);
UIMonoState_postTaskForTime(_postTaskForTime, (IntPtr) callabackHandle, _wakeupTime * MILLI_TO_NANO);
}
[MonoPInvokeCallback(typeof(UIMonoState_postTaskForTimeCallback))]

26
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs


namespace Unity.UIWidgets.engine2 {
public partial class UIWidgetsPanel : RawImage {
[Serializable]
public struct TextFont {
public string family;
[SerializeField] public Font[] fonts;
}
[Serializable]
}
[Serializable]
public struct TextFont {
public string family;
[SerializeField] public Font[] fonts;
}
public TextFont[] fonts;

_ptr = UIWidgetsPanel_constructor((IntPtr) _handle, UIWidgetsPanel_entrypoint);
var settings = new Dictionary<string, object>();
settings.Add("fonts", fontsToObject(fonts));
if (fonts != null && fonts.Length > 0) {
settings.Add("fonts", fontsToObject(fonts));
}
NativeConsole.OnEnable();
}
protected virtual void main() {

_isEntered = false;
UIWidgetsPanel_onMouseLeave(_ptr);
}
public void TakeScreenshot() {
UIWidgetsPanel_takeScreenShot(_ptr);
}
public void OnDrag(PointerEventData eventData) {
var pos = _getPointerPosition(Input.mousePosition);
if (pos == null) {

[DllImport(NativeBindings.dllName)]
static extern void UIWidgetsPanel_onMouseLeave(IntPtr ptr);
[DllImport(NativeBindings.dllName)]
static extern void UIWidgetsPanel_takeScreenShot(IntPtr ptr);
}
}

32
com.unity.uiwidgets/Runtime/external/SplayTree.cs


return new KeyValuePair<TKey, TValue>(t.Key, t.Value);
}
public TKey lastKeyBefore(TKey key) {
if (key == null) throw new Exception("should input null");
if (root == null) throw new Exception("root is null");
int comp = Splay(key);
if (comp < 0) return root.Key;
SplayTreeNode node = root.LeftChild;
if (node == null) throw new Exception("does not exist");
while (node.RightChild != null) {
node = node.RightChild;
}
return node.Key;
}
public TKey firstKeyAfter(TKey key) {
if (key == null) throw new Exception("should input null");
if (root == null) throw new Exception("root is null");
int comp = Splay(key);
if (comp > 0) return root.Key;
SplayTreeNode node = root.LeftChild;
if (node == null) throw new Exception("does not exist");
while (node.LeftChild != null) {
node = node.LeftChild;
}
return node.Key;
}
public KeyValuePair<TKey, TValue>? Last() {
SplayTreeNode t = root;

return new KeyValuePair<TKey, TValue>(t.Key, t.Value);
}
void Splay(TKey key) {
int Splay(TKey key) {
int c;
var c = key.CompareTo(t.Key);
c = key.CompareTo(t.Key);
if (c < 0) {
if (t.LeftChild == null) {
break;

t.LeftChild = header.RightChild;
t.RightChild = header.LeftChild;
root = t;
return c;
}
public bool Remove(TKey key) {

14
com.unity.uiwidgets/Runtime/foundation/debug.cs


}*/
}
}
public static int? debugFloatPrecision;
public static string debugFormatFloat(float? value) {
if (value == null) {
return "null";
}
if (debugFloatPrecision != null) {
return value.Value.ToString($"N{debugFloatPrecision}");
}
return value.Value.ToString($"N1");
}
}
[Serializable]

2
com.unity.uiwidgets/Runtime/gestures/binding.cs


using UnityEngine;
namespace Unity.UIWidgets.gestures {
public class GestureBinding : SchedulerBinding, HitTestable, HitTestDispatcher, HitTestTarget {
public class GestureBinding : BindingBase, HitTestable, HitTestDispatcher, HitTestTarget {
protected override void initInstances() {
base.initInstances();

414
com.unity.uiwidgets/Runtime/painting/alignment.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
public abstract class AlignmentGeometry {
public abstract class AlignmentGeometry : IEquatable<AlignmentGeometry> {
protected float _x { get; }
protected virtual float _x { get; }
protected float _start { get; }
protected virtual float _start { get; }
protected float _y { get; }
protected virtual float _y { get; }
// public static AlignmentGeometry add(AlignmentGeometry other) {
// return new _MixedAlignment(
// _x + other._x,
// _start + other._start,
// _y + other._y,
// );
// }
public virtual AlignmentGeometry add(AlignmentGeometry other) {
return new _MixedAlignment(
_x + other._x,
_start + other._start,
_y + other._y
);
}
// public abstract AlignmentGeometry operator -();
//
// public abstract AlignmentGeometry operator *(double other);
//
// public abstract AlignmentGeometry operator /(double other);
//
// public abstract AlignmentGeometry operator ~/(double other);
//
// public abstract AlignmentGeometry operator %(double other);
public abstract AlignmentGeometry SelfMinus();
// static AlignmentGeometry lerp(AlignmentGeometry a, AlignmentGeometry b, float t) {
// D.assert(t != null);
// if (a == null && b == null)
// return null;
// if (a == null)
// return b * t;
// if (b == null)
// return a * (1.0 - t);
// if (a is Alignment && b is Alignment)
// return Alignment.lerp(a, b, t);
// if (a is AlignmentDirectional && b is AlignmentDirectional)
// return AlignmentDirectional.lerp(a, b, t);
// return _MixedAlignment(
// ui.lerpDouble(a._x, b._x, t),
// ui.lerpDouble(a._start, b._start, t),
// ui.lerpDouble(a._y, b._y, t),
// );
// }
//
public static AlignmentGeometry operator -(AlignmentGeometry self) {
return self.SelfMinus();
}
public abstract AlignmentGeometry Multiply(float other);
public static AlignmentGeometry operator *(AlignmentGeometry self, float other) {
return self.Multiply(other);
}
public abstract AlignmentGeometry Divide(float other);
public static AlignmentGeometry operator /(AlignmentGeometry self, float other) {
return self.Divide(other);
}
public abstract AlignmentGeometry Remainder(float other);
public static AlignmentGeometry operator %(AlignmentGeometry self, float other) {
return self.Remainder(other);
}
public static AlignmentGeometry lerp(AlignmentGeometry a, AlignmentGeometry b, float t) {
D.assert(t != null);
if (a == null && b == null)
return null;
if (a == null)
return b * t;
if (b == null)
return a * (1.0f - t);
if (a is Alignment && b is Alignment)
return Alignment.lerp(a, b, t);
if (a is AlignmentDirectional && b is AlignmentDirectional)
return AlignmentDirectional.lerp(a, b, t);
return new _MixedAlignment(
Mathf.Lerp(a._x, b._x, t),
Mathf.Lerp(a._start, b._start, t),
Mathf.Lerp(a._y, b._y, t)
);
}
//
// @override
// String toString() {
// if (_start == 0.0)
// return Alignment._stringify(_x, _y);
// if (_x == 0.0)
// return AlignmentDirectional._stringify(_start, _y);
// return Alignment._stringify(_x, _y) + ' + ' + AlignmentDirectional._stringify(_start, 0.0);
// }
//
// @override
// bool operator ==(Object other) {
// return other is AlignmentGeometry
// && other._x == _x
// && other._start == _start
// && other._y == _y;
// }
//
// @override
// int get hashCode => hashValues(_x, _start, _y);
public override string ToString() {
if (_start == 0.0)
return Alignment._stringify(_x, _y);
if (_x == 0.0)
return AlignmentDirectional._stringify(_start, _y);
return Alignment._stringify(_x, _y) + " + " + AlignmentDirectional._stringify(_start, 0.0);
}
public bool Equals(AlignmentGeometry other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return _x.Equals(other._x) && _start.Equals(other._start) && _y.Equals(other._y);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((AlignmentGeometry) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = _x.GetHashCode();
hashCode = (hashCode * 397) ^ _start.GetHashCode();
hashCode = (hashCode * 397) ^ _y.GetHashCode();
return hashCode;
}
}
}
public class Alignment : AlignmentGeometry, IEquatable<Alignment> {

return new Alignment(a.x + b.x, a.y + b.y);
}
public static Alignment operator -(Alignment a) {
return new Alignment(-a.x, -a.y);
public override AlignmentGeometry SelfMinus() {
return new Alignment(-x, -y);
public static Alignment operator *(Alignment a, float b) {
return new Alignment(a.x * b, a.y * b);
public override AlignmentGeometry Multiply(float other) {
return new Alignment(x * other, y * other);
public static Alignment operator /(Alignment a, float b) {
return new Alignment(a.x / b, a.y / b);
public override AlignmentGeometry Divide(float other) {
return new Alignment(x / other, y / other);
public static Alignment operator %(Alignment a, float b) {
return new Alignment(a.x % b, a.y % b);
public override AlignmentGeometry Remainder(float other) {
return new Alignment(x % other, y % other);
}
public Offset alongOffset(Offset other) {

case TextDirection.ltr:
return new Alignment(_x + _start, _y);
}
}
internal static String _stringify(float x, float y) {
if (x == -1.0f && y == -1.0f)
return "topLeft";
if (x == 0.0f && y == -1.0f)
return "topCenter";
if (x == 1.0f && y == -1.0f)
return "topRight";
if (x == -1.0f && y == 0.0f)
return "centerLeft";
if (x == 0.0f && y == 0.0f)
return "center";
if (x == 1.0f && y == 0.0f)
return "centerRight";
if (x == -1.0f && y == 1.0f)
return "bottomLeft";
if (x == 0.0f && y == 1.0f)
return "bottomCenter";
if (x == 1.0f && y == 1.0f)
return "bottomRight";
return $"Alignment({x}, " +
$"{y})";
}
}
public class AlignmentDirectional : AlignmentGeometry {
public AlignmentDirectional(float start, float y) {
this.start = start;
this.y = y;
}
readonly float _px;
protected override float _x {
get => 0;
}
readonly float start;
protected override float _start {
get => start;
}
readonly float y;
protected override float _y {
get => y;
}
public static readonly AlignmentDirectional topStart = new AlignmentDirectional(-1.0f, -1.0f);
public static readonly AlignmentDirectional topCenter = new AlignmentDirectional(0.0f, -1.0f);
public static readonly AlignmentDirectional topEnd = new AlignmentDirectional(1.0f, -1.0f);
public static readonly AlignmentDirectional centerStart = new AlignmentDirectional(-1.0f, 0.0f);
public static readonly AlignmentDirectional center = new AlignmentDirectional(0.0f, 0.0f);
public static readonly AlignmentDirectional centerEnd = new AlignmentDirectional(1.0f, 0.0f);
public static readonly AlignmentDirectional bottomStart = new AlignmentDirectional(-1.0f, 1.0f);
public static readonly AlignmentDirectional bottomCenter = new AlignmentDirectional(0.0f, 1.0f);
public static readonly AlignmentDirectional bottomEnd = new AlignmentDirectional(1.0f, 1.0f);
public override AlignmentGeometry add(AlignmentGeometry other) {
if (other is AlignmentDirectional alignmentDirectional)
return this + alignmentDirectional;
return base.add(other);
}
public static AlignmentDirectional operator -(AlignmentDirectional self, AlignmentDirectional other) {
return new AlignmentDirectional(self.start - other.start, self.y - other.y);
}
public static AlignmentDirectional operator +(AlignmentDirectional self, AlignmentDirectional other) {
return new AlignmentDirectional(self.start + other.start, self.y + other.y);
}
public override AlignmentGeometry SelfMinus() {
return new AlignmentDirectional(-start, -y);
}
public override AlignmentGeometry Multiply(float other) {
return new AlignmentDirectional(start * other, y * other);
}
public override AlignmentGeometry Divide(float other) {
return new AlignmentDirectional(start / other, y / other);
}
public override AlignmentGeometry Remainder(float other) {
return new AlignmentDirectional(start % other, y % other);
}
static AlignmentDirectional lerp(AlignmentDirectional a, AlignmentDirectional b, float t) {
D.assert(t != null);
if (a == null && b == null)
return null;
if (a == null)
return new AlignmentDirectional(MathUtils.lerpFloat(0.0f, b.start, t),
MathUtils.lerpFloat(0.0f, b.y, t));
if (b == null)
return new AlignmentDirectional(MathUtils.lerpFloat(a.start, 0.0f, t),
MathUtils.lerpFloat(a.y, 0.0f, t));
return new AlignmentDirectional(MathUtils.lerpFloat(a.start, b.start, t), MathUtils.lerpFloat(a.y, b.y, t));
}
public override Alignment resolve(TextDirection? direction) {
D.assert(direction != null);
switch (direction) {
case TextDirection.rtl:
return new Alignment(-start, y);
case TextDirection.ltr:
return new Alignment(start, y);
}
return null;
}
internal static String _stringify(double start, double y) {
if (start == -1.0f && y == -1.0f)
return "AlignmentDirectional.topStart";
if (start == 0.0f && y == -1.0f)
return "AlignmentDirectional.topCenter";
if (start == 1.0f && y == -1.0f)
return "AlignmentDirectional.topEnd";
if (start == -1.0f && y == 0.0f)
return "AlignmentDirectional.centerStart";
if (start == 0.0f && y == 0.0f)
return "AlignmentDirectional.center";
if (start == 1.0f && y == 0.0f)
return "AlignmentDirectional.centerEnd";
if (start == -1.0f && y == 1.0f)
return "AlignmentDirectional.bottomStart";
if (start == 0.0f && y == 1.0f)
return "AlignmentDirectional.bottomCenter";
if (start == 1.0f && y == 1.0f)
return "AlignmentDirectional.bottomEnd";
return $"AlignmentDirectional({start}, {y})";
}
public override string ToString() => _stringify(start, y);
}
class _MixedAlignment : AlignmentGeometry {
internal _MixedAlignment(float _x, float _start, float _y) {
_px = _x;
_pstart = _start;
_py = _y;
}
readonly float _px;
protected override float _x {
get => _px;
}
readonly float _pstart;
protected override float _start {
get => _pstart;
}
readonly float _py;
protected override float _y {
get => _py;
}
public override AlignmentGeometry SelfMinus() {
return new _MixedAlignment(
-_x,
-_start,
-_y
);
}
public override AlignmentGeometry Multiply(float other) {
return new _MixedAlignment(
_x * other,
_start * other,
_y * other
);
}
public override AlignmentGeometry Divide(float other) {
return new _MixedAlignment(
_x / other,
_start / other,
_y / other
);
}
public override AlignmentGeometry Remainder(float other) {
return new _MixedAlignment(
_x % other,
_start % other,
_y % other
);
}
public override Alignment resolve(TextDirection? direction) {
D.assert(direction != null);
switch (direction) {
case TextDirection.rtl:
return new Alignment(_x - _start, _y);
case TextDirection.ltr:
return new Alignment(_x + _start, _y);
}
return null;
}
}
public class TextAlignVertical {
public TextAlignVertical(float y) {
D.assert(y != null);
D.assert(y >= -1.0 && y <= 1.0);
this.y = y;
}
public readonly double y;
public static readonly TextAlignVertical top = new TextAlignVertical(y: -1.0f);
public static readonly TextAlignVertical center = new TextAlignVertical(y: 0.0f);
public static readonly TextAlignVertical bottom = new TextAlignVertical(y: 1.0f);
public override string ToString() {
return $"{foundation_.objectRuntimeType(this, "TextAlignVertical")}(y: {y})";
}
}
}

18
com.unity.uiwidgets/Runtime/painting/beveled_rectangle_border.cs


public readonly BorderRadius borderRadius;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get { return EdgeInsets.all(side.width); }
}

borderRadius: borderRadius * t
borderRadius: (BorderRadius) (borderRadius * t)
);
}

return path;
}
public override Path getInnerPath(Rect rect) {
return _getPath(borderRadius.toRRect(rect).deflate(side.width));
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
return _getPath(borderRadius.resolve(textDirection).toRRect(rect).deflate(side.width));
public override Path getOuterPath(Rect rect) {
return _getPath(borderRadius.toRRect(rect));
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
return _getPath(borderRadius.resolve(textDirection).toRRect(rect));
public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null) {
if (rect.isEmpty) {
return;
}

break;
case BorderStyle.solid:
Path path = getOuterPath(rect);
path.addPath(getInnerPath(rect), Offset.zero);
Path path = getOuterPath(rect, textDirection);
path.addPath(getInnerPath(rect, textDirection), Offset.zero);
canvas.drawPath(path, side.toPaint());
break;
}

46
com.unity.uiwidgets/Runtime/painting/binding.cs


using System;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.services;
public class PaintingBinding : GestureBinding {
public class PaintingBinding : ServicesBinding {
protected override void initInstances() {
base.initInstances();
instance = this;

}
public new static PaintingBinding instance {
get { return (PaintingBinding) GestureBinding.instance; }
get { return (PaintingBinding) ServicesBinding.instance; }
set { Window.instance._binding = value; }
}

ImageCache _imageCache;
readonly _SystemFontsNotifier _systemFonts = new _SystemFontsNotifier();
public _SystemFontsNotifier systemFonts {
public Listenable systemFonts {
readonly _SystemFontsNotifier _systemFonts = new _SystemFontsNotifier();
}
public static partial class painting_ {
public static ImageCache imageCache => PaintingBinding.instance.imageCache;
public Future<ui.Codec> instantiateImageCodec(byte[] bytes,
int? cacheWidth = null,
int? cacheHeight = null
) {
D.assert(cacheWidth == null || cacheWidth > 0);
D.assert(cacheHeight == null || cacheHeight > 0);
return ui_.instantiateImageCodec(
bytes,
targetWidth: cacheWidth,
targetHeight: cacheHeight
);
}
public class _SystemFontsNotifier : Listenable {
HashSet<VoidCallback> _systemFontsCallbacks = new HashSet<VoidCallback>();
internal class _SystemFontsNotifier : Listenable {
readonly HashSet<VoidCallback> _systemFontsCallbacks = new HashSet<VoidCallback>();
void notifyListeners () {
void notifyListeners() {
public void addListener(VoidCallback listener) {
_systemFontsCallbacks.Add(listener);
}

}
}
public static partial class painting_ {
public static ImageCache imageCache => PaintingBinding.instance.imageCache;
}
}

680
com.unity.uiwidgets/Runtime/painting/border_radius.cs


using System;
using System.Text;
using Unity.UIWidgets.foundation;
public class BorderRadius : IEquatable<BorderRadius> {
public abstract class BorderRadiusGeometry : IEquatable<BorderRadiusGeometry> {
public BorderRadiusGeometry() {
}
protected virtual Radius _topLeft { get; }
protected virtual Radius _topRight { get; }
protected virtual Radius _bottomLeft { get; }
protected virtual Radius _bottomRight { get; }
protected virtual Radius _topStart { get; }
protected virtual Radius _topEnd { get; }
protected virtual Radius _bottomStart { get; }
protected virtual Radius _bottomEnd { get; }
public virtual BorderRadiusGeometry subtract(BorderRadiusGeometry other) {
return new _MixedBorderRadius(
_topLeft - other._topLeft,
_topRight - other._topRight,
_bottomLeft - other._bottomLeft,
_bottomRight - other._bottomRight,
_topStart - other._topStart,
_topEnd - other._topEnd,
_bottomStart - other._bottomStart,
_bottomEnd - other._bottomEnd
);
}
public virtual BorderRadiusGeometry add(BorderRadiusGeometry other) {
return new _MixedBorderRadius(
_topLeft + other._topLeft,
_topRight + other._topRight,
_bottomLeft + other._bottomLeft,
_bottomRight + other._bottomRight,
_topStart + other._topStart,
_topEnd + other._topEnd,
_bottomStart + other._bottomStart,
_bottomEnd + other._bottomEnd
);
}
public abstract BorderRadiusGeometry SelfMinus();
public static BorderRadiusGeometry operator -(BorderRadiusGeometry other) {
return other.SelfMinus();
}
public abstract BorderRadiusGeometry Multiply(float other);
public static BorderRadiusGeometry operator *(BorderRadiusGeometry self, float other) {
return self.Multiply(other);
}
public abstract BorderRadiusGeometry Divide(float other);
public static BorderRadiusGeometry operator /(BorderRadiusGeometry self, float other) {
return self.Divide(other);
}
public abstract BorderRadiusGeometry Remainder(float other);
public static BorderRadiusGeometry operator %(BorderRadiusGeometry self, float other) {
return self.Remainder(other);
}
public static BorderRadiusGeometry lerp(BorderRadiusGeometry a, BorderRadiusGeometry b, float t) {
if (a == null && b == null)
return null;
a = a ?? BorderRadius.zero;
b = b ?? BorderRadius.zero;
return a.add((b.subtract(a)) * t);
}
public abstract BorderRadius resolve(TextDirection? textDirection);
public override string ToString() {
String visual = null, logical = null;
if (_topLeft == _topRight &&
_topRight == _bottomLeft &&
_bottomLeft == _bottomRight) {
if (_topLeft != Radius.zero) {
if (_topLeft.x == _topLeft.y) {
visual = $"BorderRadius.circular({_topLeft.x})";
}
else {
visual = $"BorderRadius.all({_topLeft})";
}
}
}
else {
StringBuilder result = new StringBuilder();
result.Append("BorderRadius.only(");
bool comma = false;
if (_topLeft != Radius.zero) {
result.Append($"topLeft: {_topLeft}");
comma = true;
}
if (_topRight != Radius.zero) {
if (comma)
result.Append(", ");
result.Append($"topRight: {_topRight}");
comma = true;
}
if (_bottomLeft != Radius.zero) {
if (comma)
result.Append(", ");
result.Append($"bottomLeft: {_bottomLeft}");
comma = true;
}
if (_bottomRight != Radius.zero) {
if (comma)
result.Append(", ");
result.Append($"bottomRight: {_bottomRight}");
}
result.Append(")");
visual = result.ToString();
}
if (_topStart == _topEnd &&
_topEnd == _bottomEnd &&
_bottomEnd == _bottomStart) {
if (_topStart != Radius.zero) {
if (_topStart.x == _topStart.y) {
logical = $"BorderRadiusDirectional.circular({_topStart.x})";
}
else {
logical = $"BorderRadiusDirectional.all({_topStart})";
}
}
}
else {
StringBuilder result = new StringBuilder();
result.Append("BorderRadiusDirectional.only(");
bool comma = false;
if (_topStart != Radius.zero) {
result.Append($"topStart: {_topStart}");
comma = true;
}
if (_topEnd != Radius.zero) {
if (comma)
result.Append(", ");
result.Append($"topEnd: {_topEnd}");
comma = true;
}
if (_bottomStart != Radius.zero) {
if (comma)
result.Append(", ");
result.Append($"bottomStart: {_bottomStart}");
comma = true;
}
if (_bottomEnd != Radius.zero) {
if (comma)
result.Append(", ");
result.Append($"bottomEnd: {_bottomEnd}");
}
result.Append(")");
logical = result.ToString();
}
if (visual != null && logical != null)
return $"{visual} + {logical}";
if (visual != null)
return visual;
if (logical != null)
return logical;
return "BorderRadius.zero";
}
public static bool operator ==(BorderRadiusGeometry left, BorderRadiusGeometry right) {
return Equals(left, right);
}
public static bool operator !=(BorderRadiusGeometry left, BorderRadiusGeometry right) {
return Equals(left, right);
}
public bool Equals(BorderRadiusGeometry other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(_topLeft, other._topLeft) && Equals(_topRight, other._topRight) &&
Equals(_bottomLeft, other._bottomLeft) && Equals(_bottomRight, other._bottomRight) &&
Equals(_topStart, other._topStart) && Equals(_topEnd, other._topEnd) &&
Equals(_bottomStart, other._bottomStart) && Equals(_bottomEnd, other._bottomEnd);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((BorderRadiusGeometry) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = (_topLeft != null ? _topLeft.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (_topRight != null ? _topRight.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (_bottomLeft != null ? _bottomLeft.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (_bottomRight != null ? _bottomRight.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (_topStart != null ? _topStart.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (_topEnd != null ? _topEnd.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (_bottomStart != null ? _bottomStart.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (_bottomEnd != null ? _bottomEnd.GetHashCode() : 0);
return hashCode;
}
}
}
public class BorderRadius : BorderRadiusGeometry, IEquatable<BorderRadius> {
BorderRadius(
Radius topLeft,
Radius topRight,

public static readonly BorderRadius zero = all(Radius.zero);
public readonly Radius topLeft;
protected override Radius _topLeft {
get => topLeft;
}
protected override Radius _topRight {
get => topRight;
}
public readonly Radius bottomLeft;
protected override Radius _bottomLeft {
get => bottomLeft;
}
public readonly Radius bottomLeft;
protected override Radius _bottomRight {
get => bottomRight;
}
protected override Radius _topStart {
get => Radius.zero;
}
protected override Radius _topEnd {
get => Radius.zero;
}
protected override Radius _bottomStart {
get => Radius.zero;
}
protected override Radius _bottomEnd {
get => Radius.zero;
}
public RRect toRRect(Rect rect) {
return RRect.fromRectAndCorners(

);
}
public static BorderRadius operator -(BorderRadius it) {
public override BorderRadiusGeometry SelfMinus() {
topLeft: -it.topLeft,
topRight: -it.topRight,
bottomLeft: -it.bottomLeft,
bottomRight: -it.bottomRight
topLeft: -topLeft,
topRight: -topRight,
bottomLeft: -bottomLeft,
bottomRight: -bottomRight
public static BorderRadius operator *(BorderRadius it, float other) {
public override BorderRadiusGeometry Multiply(float other) {
topLeft: it.topLeft * other,
topRight: it.topRight * other,
bottomLeft: it.bottomLeft * other,
bottomRight: it.bottomRight * other
topLeft: topLeft * other,
topRight: topRight * other,
bottomLeft: bottomLeft * other,
bottomRight: bottomRight * other
public static BorderRadius operator /(BorderRadius it, float other) {
public override BorderRadiusGeometry Divide(float other) {
topLeft: it.topLeft / other,
topRight: it.topRight / other,
bottomLeft: it.bottomLeft / other,
bottomRight: it.bottomRight / other
topLeft: topLeft / other,
topRight: topRight / other,
bottomLeft: bottomLeft / other,
bottomRight: bottomRight / other
public static BorderRadius operator %(BorderRadius it, float other) {
public override BorderRadiusGeometry Remainder(float other) {
topLeft: it.topLeft % other,
topRight: it.topRight % other,
bottomLeft: it.bottomLeft % other,
bottomRight: it.bottomRight % other
topLeft: topLeft % other,
topRight: topRight % other,
bottomLeft: bottomLeft % other,
bottomRight: bottomRight % other
);
}

}
if (a == null) {
return b * t;
return (BorderRadius) (b * t);
return a * (1.0f - t);
return (BorderRadius) (a * (1.0f - t));
}
return only(

public static bool operator !=(BorderRadius a, BorderRadius b) {
return !Equals(a, b);
}
public BorderRadius resolve(TextDirection direction) => this;
public override string ToString() {
string visual = null;
if (topLeft == topRight &&
topRight == bottomLeft &&
bottomLeft == bottomRight) {
if (topLeft != Radius.zero) {
if (topLeft.x == topLeft.y) {
visual = $"BorderRadius.circular({topLeft.x:F1})";
}
else {
visual = $"BorderRadius.all({topLeft})";
}
}
}
else {
var result = new StringBuilder();
result.Append("BorderRadius.only(");
bool comma = false;
if (topLeft != Radius.zero) {
result.Append($"topLeft: {topLeft}");
comma = true;
}
public override BorderRadius resolve(TextDirection? textDirection) => this;
}
if (topRight != Radius.zero) {
if (comma) {
result.Append(", ");
}
public class BorderRadiusDirectional : BorderRadiusGeometry {
BorderRadiusDirectional(
Radius topStart,
Radius topEnd,
Radius bottomStart,
Radius bottomEnd) {
this.topStart = topStart ?? Radius.zero;
this.topEnd = topEnd ?? Radius.zero;
this.bottomStart = bottomStart ?? Radius.zero;
this.bottomEnd = bottomEnd ?? Radius.zero;
}
public static BorderRadiusDirectional all(Radius radius) {
return only(
topStart: radius,
topEnd: radius,
bottomStart: radius,
bottomEnd: radius
);
}
public static BorderRadiusDirectional circular(float radius) {
return all(
Radius.circular(radius)
);
}
public static BorderRadiusDirectional vertical(
Radius top = null,
Radius bottom = null
) {
top = top ?? Radius.zero;
bottom = bottom ?? Radius.zero;
return only(
topStart: top,
topEnd: top,
bottomStart: bottom,
bottomEnd: bottom
);
}
result.Append($"topRight: {topRight}");
comma = true;
}
public static BorderRadiusDirectional horizontal(
Radius start = null,
Radius end = null
) {
start = start ?? Radius.zero;
end = end ?? Radius.zero;
return only(
topStart: start,
topEnd: end,
bottomStart: start,
bottomEnd: end
);
}
if (bottomLeft != Radius.zero) {
if (comma) {
result.Append(", ");
}
public static BorderRadiusDirectional only(
Radius topStart,
Radius topEnd,
Radius bottomStart,
Radius bottomEnd) {
return new BorderRadiusDirectional(topStart, topEnd, bottomStart, bottomEnd);
}
result.Append($"bottomLeft: {bottomLeft}");
comma = true;
}
public static readonly BorderRadiusDirectional zero = BorderRadiusDirectional.all(Radius.zero);
if (bottomRight != Radius.zero) {
if (comma) {
result.Append(", ");
}
public readonly Radius topStart;
result.Append($"bottomRight: {bottomRight}");
}
result.Append(")");
visual = result.ToString();
protected override Radius _topStart {
get => topStart;
}
public readonly Radius topEnd;
protected override Radius _topEnd {
get => topEnd;
}
public readonly Radius bottomStart;
protected override Radius _bottomStart {
get => bottomStart;
}
public readonly Radius bottomEnd;
protected override Radius _bottomEnd {
get => bottomEnd;
}
protected override Radius _topLeft {
get => Radius.zero;
}
protected override Radius _topRight {
get => Radius.zero;
}
protected override Radius _bottomLeft {
get => Radius.zero;
}
protected override Radius _bottomRight {
get => Radius.zero;
}
public override BorderRadiusGeometry subtract(BorderRadiusGeometry other) {
if (other is BorderRadiusDirectional borderRadiusDirectional)
return this - borderRadiusDirectional;
return base.subtract(other);
}
public override BorderRadiusGeometry add(BorderRadiusGeometry other) {
if (other is BorderRadiusDirectional)
return this + (BorderRadiusDirectional) other;
return base.add(other);
}
public static BorderRadiusDirectional operator -(BorderRadiusDirectional self, BorderRadiusDirectional other) {
return BorderRadiusDirectional.only(
topStart: self.topStart - other.topStart,
topEnd: self.topEnd - other.topEnd,
bottomStart: self.bottomStart - other.bottomStart,
bottomEnd: self.bottomEnd - other.bottomEnd
);
}
public static BorderRadiusDirectional operator +(BorderRadiusDirectional other, BorderRadiusDirectional right) {
return BorderRadiusDirectional.only(
topStart: other.topStart + right.topStart,
topEnd: other.topEnd + right.topEnd,
bottomStart: other.bottomStart + right.bottomStart,
bottomEnd: other.bottomEnd + right.bottomEnd
);
}
public override BorderRadiusGeometry SelfMinus() {
return BorderRadiusDirectional.only(
topStart: -topStart,
topEnd: -topEnd,
bottomStart: -bottomStart,
bottomEnd: -bottomEnd
);
}
public override BorderRadiusGeometry Multiply(float other) {
return BorderRadiusDirectional.only(
topStart: topStart * other,
topEnd: topEnd * other,
bottomStart: bottomStart * other,
bottomEnd: bottomEnd * other
);
}
public override BorderRadiusGeometry Divide(float other) {
return BorderRadiusDirectional.only(
topStart: topStart / other,
topEnd: topEnd / other,
bottomStart: bottomStart / other,
bottomEnd: bottomEnd / other
);
}
public override BorderRadiusGeometry Remainder(float other) {
return BorderRadiusDirectional.only(
topStart: topStart % other,
topEnd: topEnd % other,
bottomStart: bottomStart % other,
bottomEnd: bottomEnd % other
);
}
public static BorderRadiusDirectional lerp(BorderRadiusDirectional a, BorderRadiusDirectional b, float t) {
if (a == null && b == null)
return null;
if (a == null)
return (BorderRadiusDirectional) (b * t);
if (b == null)
return (BorderRadiusDirectional) (a * (1.0f - t));
return BorderRadiusDirectional.only(
topStart: Radius.lerp(a.topStart, b.topStart, t),
topEnd: Radius.lerp(a.topEnd, b.topEnd, t),
bottomStart: Radius.lerp(a.bottomStart, b.bottomStart, t),
bottomEnd: Radius.lerp(a.bottomEnd, b.bottomEnd, t)
);
}
public override BorderRadius resolve(TextDirection? direction) {
switch (direction) {
case TextDirection.rtl:
return BorderRadius.only(
topLeft: topEnd,
topRight: topStart,
bottomLeft: bottomEnd,
bottomRight: bottomStart
);
case TextDirection.ltr:
return BorderRadius.only(
topLeft: topStart,
topRight: topEnd,
bottomLeft: bottomStart,
bottomRight: bottomEnd
);
if (visual != null) {
return visual;
return null;
}
}
class _MixedBorderRadius : BorderRadiusGeometry {
internal _MixedBorderRadius(
Radius _topLeft,
Radius _topRight,
Radius _bottomLeft,
Radius _bottomRight,
Radius _topStart,
Radius _topEnd,
Radius _bottomStart,
Radius _bottomEnd) {
this._topLeft = _topLeft;
this._topRight = _topRight;
this._bottomLeft = _bottomLeft;
this._bottomRight = _bottomRight;
this._topStart = _topStart;
this._topEnd = _topEnd;
this._bottomStart = _bottomStart;
this._bottomEnd = _bottomEnd;
}
protected override Radius _topLeft { get; }
protected override Radius _topRight { get; }
protected override Radius _bottomLeft { get; }
protected override Radius _bottomRight { get; }
protected override Radius _topStart { get; }
protected override Radius _topEnd { get; }
protected override Radius _bottomStart { get; }
protected override Radius _bottomEnd { get; }
public override BorderRadiusGeometry SelfMinus() {
return new _MixedBorderRadius(
-_topLeft,
-_topRight,
-_bottomLeft,
-_bottomRight,
-_topStart,
-_topEnd,
-_bottomStart,
-_bottomEnd
);
}
public override BorderRadiusGeometry Multiply(float other) {
return new _MixedBorderRadius(
_topLeft * other,
_topRight * other,
_bottomLeft * other,
_bottomRight * other,
_topStart * other,
_topEnd * other,
_bottomStart * other,
_bottomEnd * other
);
}
public override BorderRadiusGeometry Divide(float other) {
return new _MixedBorderRadius(
_topLeft / other,
_topRight / other,
_bottomLeft / other,
_bottomRight / other,
_topStart / other,
_topEnd / other,
_bottomStart / other,
_bottomEnd / other
);
}
public override BorderRadiusGeometry Remainder(float other) {
return new _MixedBorderRadius(
_topLeft % other,
_topRight % other,
_bottomLeft % other,
_bottomRight % other,
_topStart % other,
_topEnd % other,
_bottomStart % other,
_bottomEnd % other
);
}
public override BorderRadius resolve(TextDirection? direction) {
switch (direction) {
case TextDirection.rtl:
return BorderRadius.only(
topLeft: _topLeft + _topEnd,
topRight: _topRight + _topStart,
bottomLeft: _bottomLeft + _bottomEnd,
bottomRight: _bottomRight + _bottomStart
);
case TextDirection.ltr:
return BorderRadius.only(
topLeft: _topLeft + _topStart,
topRight: _topRight + _topEnd,
bottomLeft: _bottomLeft + _bottomStart,
bottomRight: _bottomRight + _bottomEnd
);
return "BorderRadius.zero";
return null;
}
}
}

26
com.unity.uiwidgets/Runtime/painting/borders.cs


}
public override string ToString() {
return $"{GetType()}({color}, {width:F1}, {style})";
return $"{foundation_.objectRuntimeType(this, "BorderSize")}({color}, {width:F1}, {style})";
}
}

public abstract EdgeInsets dimensions { get; }
public virtual EdgeInsetsGeometry dimensions { get; }
public virtual ShapeBorder add(ShapeBorder other, bool reversed = false) {
return null;

return result ?? (t < 0.5 ? a : b);
}
public abstract Path getOuterPath(Rect rect);
public abstract Path getOuterPath(Rect rect, TextDirection? textDirection = null);
public abstract Path getInnerPath(Rect rect);
public abstract Path getInnerPath(Rect rect, TextDirection? textDirection = null);
public abstract void paint(Canvas canvas, Rect rect);
public abstract void paint(Canvas canvas, Rect rect, TextDirection? textDirection);
return $"{GetType()}()";
return $"{foundation_.objectRuntimeType(this, "BorderShape")}()";
}
}

public readonly List<ShapeBorder> borders;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get {
return borders.Aggregate(
EdgeInsets.zero,

return new _CompoundBorder(results);
}
public override Path getInnerPath(Rect rect) {
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
rect = borders[index].dimensions.deflateRect(rect);
rect = borders[index].dimensions.resolve(textDirection).deflateRect(rect);
public override Path getOuterPath(Rect rect) {
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null) {
border.paint(canvas, rect);
rect = border.dimensions.deflateRect(rect);
border.paint(canvas, rect, textDirection);
rect = border.dimensions.resolve(textDirection).deflateRect(rect);
}
}

459
com.unity.uiwidgets/Runtime/painting/box_border.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting {

}
public class Border : ShapeBorder, IEquatable<Border> {
public abstract class BoxBorder : ShapeBorder {
public BoxBorder() {
isUniform = false;
}
public virtual BorderSide top { get; }
public virtual BorderSide bottom { get; }
public virtual bool isUniform { get; }
public override ShapeBorder add(ShapeBorder other, bool reversed = false) => null;
public static BoxBorder lerp(BoxBorder a, BoxBorder b, float t) {
D.assert(t != null);
if ((a is Border || a == null) && (b is Border || b == null))
return Border.lerp((Border) a, (Border) b, t);
if ((a is BorderDirectional || a == null) && (b is BorderDirectional || b == null))
return BorderDirectional.lerp(a as BorderDirectional, b as BorderDirectional, t);
if (b is Border && a is BorderDirectional) {
BoxBorder c = b;
b = a;
a = c;
t = 1.0f - t;
}
if (a is Border border && b is BorderDirectional borderDirectional) {
if (borderDirectional.start == BorderSide.none && borderDirectional.end == BorderSide.none) {
return new Border(
top: BorderSide.lerp(border.top, borderDirectional.top, t),
right: BorderSide.lerp(border.right, BorderSide.none, t),
bottom: BorderSide.lerp(border.bottom, borderDirectional.bottom, t),
left: BorderSide.lerp(border.left, BorderSide.none, t)
);
}
if (border.left == BorderSide.none && border.right == BorderSide.none) {
return new BorderDirectional(
top: BorderSide.lerp(border.top, borderDirectional.top, t),
start: BorderSide.lerp(BorderSide.none, borderDirectional.start, t),
end: BorderSide.lerp(BorderSide.none, borderDirectional.end, t),
bottom: BorderSide.lerp(border.bottom, borderDirectional.bottom, t)
);
}
if (t < 0.5f) {
return new Border(
top: BorderSide.lerp(border.top, borderDirectional.top, t),
right: BorderSide.lerp(border.right, BorderSide.none, t * 2.0f),
bottom: BorderSide.lerp(border.bottom, borderDirectional.bottom, t),
left: BorderSide.lerp(border.left, BorderSide.none, t * 2.0f)
);
}
return new BorderDirectional(
top: BorderSide.lerp(border.top, borderDirectional.top, t),
start: BorderSide.lerp(BorderSide.none, borderDirectional.start, (t - 0.5f) * 2.0f),
end: BorderSide.lerp(BorderSide.none, borderDirectional.end, (t - 0.5f) * 2.0f),
bottom: BorderSide.lerp(border.bottom, borderDirectional.bottom, t)
);
}
throw new UIWidgetsError(new List<DiagnosticsNode>() {
new ErrorSummary("BoxBorder.lerp can only interpolate Border and BorderDirectional classes."),
new ErrorDescription(
"BoxBorder.lerp() was called with two objects of type ${a.runtimeType} and ${b.runtimeType}:\n" +
" $a\n" +
" $b\n" +
"However, only Border and BorderDirectional classes are supported by this method."
),
new ErrorHint("For a more general interpolation method, consider using ShapeBorder.lerp instead.")
});
}
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
D.assert(textDirection != null,
() => "The textDirection argument to $runtimeType.getInnerPath must not be null.");
var result = new Path();
result.addRect(dimensions.resolve(textDirection).deflateRect(rect));
return result;
}
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
D.assert(textDirection != null,
() => "The textDirection argument to $runtimeType.getOuterPath must not be null.");
var result = new Path();
result.addRect(rect);
return result;
}
public virtual void paint(
Canvas canvas,
Rect rect,
TextDirection? textDirection = null,
BoxShape shape = BoxShape.rectangle,
BorderRadius borderRadus = null
) {
paint(canvas, rect, textDirection);
}
internal static void _paintUniformBorderWithRadius(Canvas canvas, Rect rect, BorderSide side,
BorderRadius borderRadius) {
D.assert(side.style != BorderStyle.none);
Paint paint = new Paint();
paint.color = side.color;
RRect outer = borderRadius.toRRect(rect);
float width = side.width;
if (width == 0.0f) {
paint.style = PaintingStyle.stroke;
paint.strokeWidth = 0.0f;
canvas.drawRRect(outer, paint);
}
else {
RRect inner = outer.deflate(width);
canvas.drawDRRect(outer, inner, paint);
}
}
internal static void _paintUniformBorderWithCircle(Canvas canvas, Rect rect, BorderSide side) {
D.assert(side.style != BorderStyle.none);
float width = side.width;
Paint paint = side.toPaint();
float radius = (rect.shortestSide - width) / 2.0f;
canvas.drawCircle(rect.center, radius, paint);
}
internal static void _paintUniformBorderWithRectangle(Canvas canvas, Rect rect, BorderSide side) {
D.assert(side.style != BorderStyle.none);
float width = side.width;
Paint paint = side.toPaint();
canvas.drawRect(rect.deflate(width / 2.0f), paint);
}
}
public class Border : BoxBorder, IEquatable<Border> {
public Border(
BorderSide top = null,
BorderSide right = null,

public readonly BorderSide bottom;
public readonly BorderSide left;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get {
return EdgeInsets.fromLTRB(
left.width,

);
}
public override void paint(Canvas canvas, Rect rect) {
paint(canvas, rect, BoxShape.rectangle, null);
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection) {
paint(canvas, rect, textDirection);
TextDirection? textDirection = null,
BoxShape shape = BoxShape.rectangle,
BorderRadius borderRadius = null) {
if (isUniform) {

BorderUtils.paintBorder(canvas, rect,
top: top, right: right, bottom: bottom, left: left);
}
public override Path getInnerPath(Rect rect) {
var path = new Path();
path.addRect(dimensions.deflateRect(rect));
return path;
}
public override Path getOuterPath(Rect rect) {
var path = new Path();
path.addRect(rect);
return path;
}
static void _paintUniformBorderWithRadius(Canvas canvas, Rect rect, BorderSide side,

}
}
public override string ToString() {
if (isUniform) {
return $"{GetType()}.all({top})";

}
return $"{GetType()}({string.Join(", ", arguments)})";
}
}
public class BorderDirectional : BoxBorder, IEquatable<BorderDirectional> {
public BorderDirectional(
BorderSide top,
BorderSide start,
BorderSide end,
BorderSide bottom
) {
if (top == null) {
this.top = BorderSide.none;
}
if (start == null) {
this.start = BorderSide.none;
}
if (end == null) {
this.end = BorderSide.none;
}
if (bottom == null) {
this.bottom = BorderSide.none;
}
this.top = top;
this.start = start;
this.end = end;
this.bottom = bottom;
}
static BorderDirectional merge(BorderDirectional a, BorderDirectional b) {
D.assert(a != null);
D.assert(b != null);
D.assert(BorderSide.canMerge(a.top, b.top));
D.assert(BorderSide.canMerge(a.start, b.start));
D.assert(BorderSide.canMerge(a.end, b.end));
D.assert(BorderSide.canMerge(a.bottom, b.bottom));
return new BorderDirectional(
top: BorderSide.merge(a.top, b.top),
start: BorderSide.merge(a.start, b.start),
end: BorderSide.merge(a.end, b.end),
bottom: BorderSide.merge(a.bottom, b.bottom)
);
}
public override BorderSide top { get; }
public readonly BorderSide start;
public readonly BorderSide end;
public override BorderSide bottom { get; }
public override EdgeInsetsGeometry dimensions {
get => EdgeInsetsDirectional.fromSTEB(start.width, top.width, end.width, bottom.width);
}
public override bool isUniform {
get {
Color topColor = top.color;
if (start.color != topColor ||
end.color != topColor ||
bottom.color != topColor)
return false;
float topWidth = top.width;
if (start.width != topWidth ||
end.width != topWidth ||
bottom.width != topWidth)
return false;
BorderStyle topStyle = top.style;
if (start.style != topStyle ||
end.style != topStyle ||
bottom.style != topStyle)
return false;
return true;
}
}
public override ShapeBorder add(ShapeBorder other, bool reversed = false) {
if (other is BorderDirectional otherBorderDirectional) {
BorderDirectional typedOther = otherBorderDirectional;
if (BorderSide.canMerge(top, typedOther.top) &&
BorderSide.canMerge(start, typedOther.start) &&
BorderSide.canMerge(end, typedOther.end) &&
BorderSide.canMerge(bottom, typedOther.bottom)) {
return BorderDirectional.merge(this, typedOther);
}
return null;
}
if (other is Border otherBorder) {
Border typedOther = otherBorder;
if (!BorderSide.canMerge(typedOther.top, top) ||
!BorderSide.canMerge(typedOther.bottom, bottom))
return null;
if (start != BorderSide.none ||
end != BorderSide.none) {
if (typedOther.left != BorderSide.none ||
typedOther.right != BorderSide.none)
return null;
D.assert(typedOther.left == BorderSide.none);
D.assert(typedOther.right == BorderSide.none);
return new BorderDirectional(
top: BorderSide.merge(typedOther.top, top),
start: start,
end: end,
bottom: BorderSide.merge(typedOther.bottom, bottom)
);
}
D.assert(start == BorderSide.none);
D.assert(end == BorderSide.none);
return new Border(
top: BorderSide.merge(typedOther.top, top),
right: typedOther.right,
bottom: BorderSide.merge(typedOther.bottom, bottom),
left: typedOther.left
);
}
return null;
}
public override ShapeBorder scale(float t) {
return new BorderDirectional(
top: top.scale(t),
start: start.scale(t),
end: end.scale(t),
bottom: bottom.scale(t)
);
}
public override ShapeBorder lerpFrom(ShapeBorder a, float t) {
if (a is BorderDirectional borderDirectional)
return BorderDirectional.lerp(borderDirectional, this, t);
return base.lerpFrom(a, t);
}
public override ShapeBorder lerpTo(ShapeBorder b, float t) {
if (b is BorderDirectional borderDirectional)
return BorderDirectional.lerp(this, borderDirectional, t);
return base.lerpTo(b, t);
}
public static BorderDirectional lerp(BorderDirectional a, BorderDirectional b, float t) {
D.assert(t != null);
if (a == null && b == null)
return null;
if (a == null)
return (BorderDirectional) b.scale(t);
if (b == null)
return (BorderDirectional) a.scale(1.0f - t);
return new BorderDirectional(
top: BorderSide.lerp(a.top, b.top, t),
end: BorderSide.lerp(a.end, b.end, t),
bottom: BorderSide.lerp(a.bottom, b.bottom, t),
start: BorderSide.lerp(a.start, b.start, t)
);
}
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection) {
paint(canvas, rect, textDirection);
}
public override void paint(
Canvas canvas,
Rect rect,
TextDirection? textDirection = null,
BoxShape shape = BoxShape.rectangle,
BorderRadius borderRadius = null
) {
if (isUniform) {
switch (top.style) {
case BorderStyle.none:
return;
case BorderStyle.solid:
switch (shape) {
case BoxShape.circle:
D.assert(borderRadius == null,
() => "A borderRadius can only be given for rectangular boxes.");
BoxBorder._paintUniformBorderWithCircle(canvas, rect, top);
break;
case BoxShape.rectangle:
if (borderRadius != null) {
BoxBorder._paintUniformBorderWithRadius(canvas, rect, top, borderRadius);
return;
}
BoxBorder._paintUniformBorderWithRectangle(canvas, rect, top);
break;
}
return;
}
}
D.assert(borderRadius == null, () => "A borderRadius can only be given for uniform borders.");
D.assert(shape == BoxShape.rectangle, () => "A border can only be drawn as a circle if it is uniform.");
BorderSide left = null, right = null;
D.assert(textDirection != null,
() => "Non-uniform BorderDirectional objects require a TextDirection when painting.");
switch (textDirection) {
case TextDirection.rtl:
left = end;
right = start;
break;
case TextDirection.ltr:
left = start;
right = end;
break;
}
BorderUtils.paintBorder(canvas, rect, top: top, left: left, bottom: bottom, right: right);
}
public override string ToString() {
List<String> arguments = new List<string>();
if
(top != BorderSide.none) {
arguments.Add("top: $top");
}
if (start != BorderSide.none) {
arguments.Add("start: $start");
}
if (end != BorderSide.none) {
arguments.Add("end: $end");
}
if (bottom != BorderSide.none) {
arguments.Add("bottom: $bottom");
}
return $"{foundation_.objectRuntimeType(this, "BorderDirectional")}({String.Join(", ", arguments)}";
}
public bool Equals(BorderDirectional other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(start, other.start) && Equals(end, other.end) && Equals(top, other.top) &&
Equals(bottom, other.bottom);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((BorderDirectional) obj);
}
public static bool operator ==(BorderDirectional left, object right) {
if (left is null) {
return right is null;
}
return left.Equals(right);
}
public static bool operator !=(BorderDirectional left, object right) {
if (left is null) {
return !(right is null);
}
return !left.Equals(right);
}
public override int GetHashCode() {
unchecked {
var hashCode = (start != null ? start.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (end != null ? end.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (top != null ? top.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (bottom != null ? bottom.GetHashCode() : 0);
return hashCode;
}
}
}
}

2
com.unity.uiwidgets/Runtime/painting/box_decoration.cs


public readonly BlendMode? backgroundBlendMode;
public readonly BoxShape shape;
public override EdgeInsets padding {
public override EdgeInsetsGeometry padding {
get { return border?.dimensions; }
}

11
com.unity.uiwidgets/Runtime/painting/circle_border.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;

public readonly BorderSide side;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get { return EdgeInsets.all(side.width); }
}

return base.lerpTo(b, t);
}
public override Path getInnerPath(Rect rect) {
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
var path = new Path();
path.addOval(Rect.fromCircle(
center: rect.center,

}
public override Path getOuterPath(Rect rect) {
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
var path = new Path();
path.addOval(Rect.fromCircle(
center: rect.center,

}
public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null) {
switch (side.style) {
case BorderStyle.none:
break;

}
public override string ToString() {
return $"{GetType()}({side})";
return $"{foundation_.objectRuntimeType(this, "CircleBorder")}({side})";
}
}
}

276
com.unity.uiwidgets/Runtime/painting/colors.cs


using System;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
public partial class painting_ {
internal static float _getHue(float red, float green, float blue, float max, float delta) {
float hue = 0;
if (max == 0.0f) {
hue = 0.0f;
}
else if (max == red) {
hue = 60.0f * (((green - blue) / delta) % 6);
}
else if (max == green) {
hue = 60.0f * (((blue - red) / delta) + 2);
}
else if (max == blue) {
hue = 60.0f * (((red - green) / delta) + 4);
}
return hue;
}
internal static Color _colorFromHue(
float alpha,
float hue,
float chroma,
float secondary,
float match
) {
float red;
float green;
float blue;
if (hue < 60.0f) {
red = chroma;
green = secondary;
blue = 0.0f;
}
else if (hue < 120.0f) {
red = secondary;
green = chroma;
blue = 0.0f;
}
else if (hue < 180.0f) {
red = 0.0f;
green = chroma;
blue = secondary;
}
else if (hue < 240.0f) {
red = 0.0f;
green = secondary;
blue = chroma;
}
else if (hue < 300.0f) {
red = secondary;
green = 0.0f;
blue = chroma;
}
else {
red = chroma;
green = 0.0f;
blue = secondary;
}
return Color.fromARGB((alpha * 0xFF).round(), ((red + match) * 0xFF).round(),
((green + match) * 0xFF).round(), ((blue + match) * 0xFF).round());
}
}
public class HSVColor {
HSVColor(float alpha, float hue, float saturation, float value) {
D.assert(this.alpha >= 0);

float secondary = chroma * (1.0f - (((hue / 60.0f) % 2.0f) - 1.0f).abs());
float match = value - chroma;
return ColorUtils._colorFromHue(alpha, hue, chroma, secondary, match);
return painting_._colorFromHue(alpha, hue, chroma, secondary, match);
}
public readonly float alpha;

public override string ToString() {
return $"{foundation_.objectRuntimeType(this, "HSVColor")}({alpha}, {hue}, {saturation},{value})";
}
public class HSLColor : IEquatable<HSLColor> {
private HSLColor(float alpha,
float hue,
float saturation,
float lightness) {
this.alpha = alpha;
this.hue = hue;
this.saturation = saturation;
this.lightness = lightness;
}
public static HSLColor fromAHSL(float alpha, float hue, float saturation, float lightness) {
D.assert(alpha >= 0.0f);
D.assert(alpha <= 1.0f);
D.assert(hue >= 0.0f);
D.assert(hue <= 360.0f);
D.assert(saturation >= 0.0f);
D.assert(saturation <= 1.0f);
D.assert(lightness >= 0.0f);
D.assert(lightness <= 1.0f);
return new HSLColor(alpha, hue, saturation, lightness);
}
public static HSLColor fromColor(Color color) {
float red = color.red / 0xFF;
float green = color.green / 0xFF;
float blue = color.blue / 0xFF;
float max = Mathf.Max(red, Mathf.Max(green, blue));
float min = Mathf.Min(red, Mathf.Min(green, blue));
float delta = max - min;
float alpha = color.alpha / 0xFF;
float hue = painting_._getHue(red, green, blue, max, delta);
float lightness = (max + min) / 2.0f;
float saturation = lightness == 1.0f
? 0.0f
: ((delta / (1.0f - Mathf.Abs(2.0f * lightness - 1.0f))).clamp(0.0f, 1.0f));
return HSLColor.fromAHSL(alpha, hue, saturation, lightness);
}
readonly float alpha;
readonly float hue;
readonly float saturation;
readonly float lightness;
HSLColor withAlpha(float alpha) {
return HSLColor.fromAHSL(alpha, hue, saturation, lightness);
}
HSLColor withHue(float hue) {
return HSLColor.fromAHSL(alpha, hue, saturation, lightness);
}
HSLColor withSaturation(float saturation) {
return HSLColor.fromAHSL(alpha, hue, saturation, lightness);
}
HSLColor withLightness(float lightness) {
return HSLColor.fromAHSL(alpha, hue, saturation, lightness);
}
Color toColor() {
float chroma = Mathf.Abs(1.0f - (2.0f * lightness - 1.0f) * saturation);
float secondary = chroma * (1.0f - Mathf.Abs(((hue / 60.0f) % 2.0f) - 1.0f));
float match = lightness - chroma / 2.0f;
return painting_._colorFromHue(alpha, hue, chroma, secondary, match);
}
HSLColor _scaleAlpha(float factor) {
return withAlpha(alpha * factor);
}
static HSLColor lerp(HSLColor a, HSLColor b, float t) {
D.assert(t != null);
if (a == null && b == null)
return null;
if (a == null)
return b._scaleAlpha(t);
if (b == null)
return a._scaleAlpha(1.0f - t);
return HSLColor.fromAHSL(
Mathf.Lerp(a.alpha, b.alpha, t).clamp(0.0f, 1.0f),
Mathf.Lerp(a.hue, b.hue, t) % 360.0f,
Mathf.Lerp(a.saturation, b.saturation, t).clamp(0.0f, 1.0f),
Mathf.Lerp(a.lightness, b.lightness, t).clamp(0.0f, 1.0f)
);
}
public override string ToString() {
return $"{foundation_.objectRuntimeType(this, "HSLColor")}({alpha}, {hue}, {saturation}, {lightness})";
}
public static bool operator ==(HSLColor left, HSLColor right) {
return Equals(left, right);
}
public static bool operator !=(HSLColor left, HSLColor right) {
return !Equals(left, right);
}
public bool Equals(HSLColor other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return alpha.Equals(other.alpha) && hue.Equals(other.hue) && saturation.Equals(other.saturation) &&
lightness.Equals(other.lightness);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((HSLColor) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = alpha.GetHashCode();
hashCode = (hashCode * 397) ^ hue.GetHashCode();
hashCode = (hashCode * 397) ^ saturation.GetHashCode();
hashCode = (hashCode * 397) ^ lightness.GetHashCode();
return hashCode;
}
}
}
public class ColorSwatch<T> : Color {
public ColorSwatch(
uint primary,

return GetType() + "(primary value: " + base.ToString() + ")";
}
}
public class ColorProperty : DiagnosticsProperty<Color> {
public ColorProperty(
string name = "",

D.assert(showName != null);
D.assert(style != null);
D.assert(level != null);
}
public override Dictionary<string, object> toJsonMap(DiagnosticsSerializationDelegate Delegate) {
}
public override Dictionary<string, object> toJsonMap(DiagnosticsSerializationDelegate Delegate) {
Dictionary<string, object> json = base.toJsonMap(Delegate);
if (value != null) {
json["valueProperties"] = new Dictionary<string, object> {

{"alpha", value.alpha}
};
}
}
}
public static class ColorUtils {
internal static Color _colorFromHue(
float alpha,
float hue,
float chroma,
float secondary,
float match
) {
float red;
float green;
float blue;
if (hue < 60.0) {
red = chroma;
green = secondary;
blue = 0.0f;
}
else if (hue < 120.0) {
red = secondary;
green = chroma;
blue = 0.0f;
}
else if (hue < 180.0) {
red = 0.0f;
green = chroma;
blue = secondary;
}
else if (hue < 240.0) {
red = 0.0f;
green = secondary;
blue = chroma;
}
else if (hue < 300.0) {
red = secondary;
green = 0.0f;
blue = chroma;
}
else {
red = chroma;
green = 0.0f;
blue = secondary;
}
return Color.fromARGB((alpha * 0xFF).round(),
((red + match) * 0xFF).round(),
((green + match) * 0xFF).round(), ((blue + match) * 0xFF).round());
}
}
}

26
com.unity.uiwidgets/Runtime/painting/continuous_rectangle_border.cs


public readonly BorderSide side;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get {
return EdgeInsets.all(side.width);
}

return new ContinuousRectangleBorder(
side: side.scale(t),
borderRadius: borderRadius * t
borderRadius: (BorderRadius) (borderRadius * t)
);
}

path.cubicTo(left, top, left, top, left + tlRadiusY, top);
path.lineTo(right - trRadiusX, top);
path.cubicTo(right, top, right, top, right, top + trRadiusY);
path.lineTo(right, bottom - blRadiusX);
path.cubicTo(right, bottom, right, bottom, right - blRadiusY, bottom);
path.lineTo(left + brRadiusX, bottom);
path.cubicTo(left, bottom, left, bottom, left, bottom - brRadiusY);
path.lineTo(right, bottom - brRadiusX);
path.cubicTo(right, bottom, right, bottom, right - brRadiusY, bottom);
path.lineTo(left + blRadiusX, bottom);
path.cubicTo(left, bottom, left, bottom, left, bottom - blRadiusY);
public override Path getInnerPath(Rect rect) {
return _getPath(borderRadius.toRRect(rect).deflate(side.width));
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
return _getPath(borderRadius.resolve(textDirection).toRRect(rect).deflate(side.width));
public override Path getOuterPath(Rect rect) {
return _getPath(borderRadius.toRRect(rect));
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
return _getPath(borderRadius.resolve(textDirection).toRRect(rect));
public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null) {
if (rect.isEmpty) {
return;
}

break;
case BorderStyle.solid:
Path path = getOuterPath(rect);
Path path = getOuterPath(rect, textDirection);
Paint paint = side.toPaint();
canvas.drawPath(path, paint);
break;

}
public override string ToString() {
return $"{GetType()}({side}, {borderRadius})";
return $"{foundation_.objectRuntimeType(this, "ContinuousRectangleBorder")}({side}, {borderRadius})";
}
}
}

4
com.unity.uiwidgets/Runtime/painting/decoration.cs


}
public override string toStringShort() {
return GetType().ToString();
return foundation_.objectRuntimeType(this, "Decoration");
}
public virtual bool debugAssertIsValid() {

public virtual EdgeInsets padding {
public virtual EdgeInsetsGeometry padding {
get { return EdgeInsets.zero; }
}

69
com.unity.uiwidgets/Runtime/painting/decoration_image.cs


public class DecorationImage : IEquatable<DecorationImage> {
public DecorationImage(
ImageProvider image = null,
ImageErrorListener onError = null,
ImageRepeat repeat = ImageRepeat.noRepeat
ImageRepeat repeat = ImageRepeat.noRepeat,
bool matchTextDirection = false
this.onError = onError;
this.matchTextDirection = matchTextDirection;
public readonly ImageErrorListener onError;
public readonly bool matchTextDirection;
public DecorationImagePainter createPainter(VoidCallback onChanged) {
D.assert(onChanged != null);

D.assert(rect != null);
D.assert(configuration != null);
bool flipHorizontally = false;
if (_details.matchTextDirection) {
D.assert(() => {
// We check this first so that the assert will fire immediately, not just
// when the image is ready.
if (configuration.textDirection == null) {
throw new UIWidgetsError(new List<DiagnosticsNode>() {
new ErrorSummary(
"DecorationImage.matchTextDirection can only be used when a TextDirection is available."),
new ErrorDescription(
"When DecorationImagePainter.paint() was called, there was no text direction provided " +
"in the ImageConfiguration object to match."
),
new DiagnosticsProperty<DecorationImage>("The DecorationImage was", _details,
style: DiagnosticsTreeStyle.errorProperty),
new DiagnosticsProperty<ImageConfiguration>("The ImageConfiguration was", configuration,
style: DiagnosticsTreeStyle.errorProperty)
});
}
return true;
});
if (configuration.textDirection == TextDirection.rtl)
flipHorizontally = true;
}
_imageStream?.removeListener(_imageListener);
ImageStreamListener listener = new ImageStreamListener(
_handleImage,
onError: _details.onError
);
_imageStream?.removeListener(listener);
_imageStream.addListener(_imageListener);
_imageStream.addListener(listener);
}
if (_image == null) {

canvas.clipPath(clipPath);
}
ImageUtils.paintImage(
painting_.paintImage(
canvas: canvas,
rect: rect,
image: _image.image,

alignment: _details.alignment,
centerSlice: _details.centerSlice,
repeat: _details.repeat
repeat: _details.repeat,
flipHorizontally: flipHorizontally,
filterQuality: FilterQuality.low
);
if (clipPath != null) {

void _imageListener(ImageInfo value, bool synchronousCall) {
void _handleImage(ImageInfo value, bool synchronousCall) {
if (_image == value) {
return;
}

}
public void Dispose() {
_imageStream?.removeListener(_imageListener);
_imageStream?.removeListener(new ImageStreamListener(
_handleImage,
onError: _details.onError
));
}
public override string ToString() {

public static class ImageUtils {
public static partial class painting_ {
public static void paintImage(
Canvas canvas = null,
Rect rect = null,

Alignment alignment = null,
Rect centerSlice = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
bool flipHorizontally = false,
bool invertColors = false,
FilterQuality filterQuality = FilterQuality.low
) {

float halfWidthDelta = (outputSize.width - destinationSize.width) / 2.0f;
float halfHeightDelta = (outputSize.height - destinationSize.height) / 2.0f;
float dx = halfWidthDelta + alignment.x * halfWidthDelta;
float dx = halfWidthDelta + (flipHorizontally ? -alignment.x : alignment.x) * halfWidthDelta;
bool needSave = repeat != ImageRepeat.noRepeat;
bool needSave = repeat != ImageRepeat.noRepeat || flipHorizontally;
}
if (flipHorizontally) {
float dxInside = -(rect.left + rect.width / 2.0f);
canvas.translate(-dxInside, 0.0f);
canvas.scale(-1.0f, 1.0f);
canvas.translate(dxInside, 0.0f);
}
if (repeat != ImageRepeat.noRepeat) {

42
com.unity.uiwidgets/Runtime/painting/edge_insets.cs


public abstract class EdgeInsetsGeometry {
float _bottom { get; }
float _end { get; }
float _left { get; }
float _right { get; }
float _start { get; }
float _top { get; }
internal float _bottom { get; }
internal float _end { get; }
internal float _left { get; }
internal float _right { get; }
internal float _start { get; }
internal float _top { get; }
public static EdgeInsetsGeometry infinity = _MixedEdgeInsets.fromLRSETB(

);
}
EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
public virtual EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
return _MixedEdgeInsets.fromLRSETB(
_left.clamp(min._left, max._left),
_right.clamp(min._right, max._right),

}
public abstract EdgeInsets resolve(TextDirection direction);
public abstract EdgeInsets resolve(TextDirection? direction);
public bool Equals(EdgeInsetsGeometry other) {
if (ReferenceEquals(null, other)) {

);
}
public override EdgeInsets resolve(TextDirection direction) {
public override EdgeInsets resolve(TextDirection? direction) {
D.assert(direction != null);
switch (direction) {
case TextDirection.rtl:

);
}
public override EdgeInsets resolve(TextDirection direction) {
public override EdgeInsets resolve(TextDirection? direction) {
D.assert(direction != null);
switch (direction) {
case TextDirection.rtl:

);
}
public EdgeInsets add(EdgeInsets other) {
public EdgeInsets add(EdgeInsetsGeometry other) {
left + other.left,
top + other.top,
right + other.right,
bottom + other.bottom
left + other._left,
top + other._top,
right + other._right,
bottom + other._bottom
public EdgeInsets clamp(EdgeInsets min, EdgeInsets max) {
public override EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
left.clamp(min.left, min.left),
top.clamp(min.top, min.top),
right.clamp(min.right, min.right),
bottom.clamp(min.bottom, min.bottom)
left.clamp(min._left, max._left),
top.clamp(min._top, max._top),
right.clamp(min._right, max._right),
bottom.clamp(min._bottom, max._bottom)
);
}

&& bottom.Equals(other.bottom);
}
public override EdgeInsets resolve(TextDirection direction) {
public override EdgeInsets resolve(TextDirection? direction) {
return this;
}

10
com.unity.uiwidgets/Runtime/painting/gradient.cs


}
public readonly List<Color> colors;
public readonly List<float> stops;
public readonly GradientTransform transform;

}
public override string ToString() {
return $"{GetType()}({begin}, {end}," +
return $"{foundation_.objectRuntimeType(this, "LinearGradient")}({begin}, {end}," +
$"{colors.toStringList()}, {stops.toStringList()}, {tileMode})";
}
}

}
public override string ToString() {
return $"{GetType()}({center}, {radius}," +
return $"{foundation_.objectRuntimeType(this, "RadialGradient")}({center}, {radius}," +
$"{colors.toStringList()}, {stops.toStringList()}, {tileMode})";
}
}

}
public override string ToString() {
return $"{GetType()}({center}, {startAngle}, {endAngle}, " +
$"{colors.toStringList()}, {stops.toStringList()}, {tileMode})";
return $"{foundation_.objectRuntimeType(this, "SweepGradient")}({center}, {startAngle}," +
$" {endAngle}, {colors.toStringList()}, {stops.toStringList()}, {tileMode})";
}
}
}

233
com.unity.uiwidgets/Runtime/painting/image_cache.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
//TODO: TimeLineTask
public class ImageCache {
const int _kDefaultSize = 1000;
const int _kDefaultSizeBytes = 100 << 20; // 100 MiB

readonly Dictionary<object, _CachedImage> _cache = new Dictionary<object, _CachedImage>();
readonly Dictionary<object, _LiveImage> _liveImages = new Dictionary<object, _LiveImage>();
readonly LinkedList<object> _lruKeys = new LinkedList<object>();
int _maximumSize = _kDefaultSize;

_lruKeys.Clear();
}
public bool evict(object key) {
public bool evict(object key, bool includeLive = true) {
if (includeLive) {
_LiveImage liveImage = _liveImages.getOrDefault(key);
_liveImages.Remove(key);
liveImage?.removeListener();
}
D.assert(key != null);
if (_pendingImages.TryGetValue(key, out var pendingImage)) {

}
if (_cache.TryGetValue(key, out var image)) {
_currentSizeBytes -= image.sizeBytes;
_currentSizeBytes -= image.sizeBytes ?? 0;
_cache.Remove(key);
_lruKeys.Remove(image.node);
return true;

}
void _touch(Object key, _CachedImage image) {
// D.assert(foundation_.kReleaseMode);
if (image.sizeBytes != null && image.sizeBytes <= maximumSizeBytes) {
_currentSizeBytes += image.sizeBytes ?? 0;
_cache[key] = image;
// _checkCacheSize(timelineTask);
}
}
void _trackLiveImage(Object key, _LiveImage image, bool debugPutOk = true) {
var imageOut = _liveImages.putIfAbsent(key, () => {
D.assert(debugPutOk);
image.completer.addOnLastListenerRemovedCallback(image.handleRemove);
return image;
});
imageOut.sizeBytes = image.sizeBytes ?? image.sizeBytes;
}
public ImageStreamCompleter putIfAbsent(object key, Func<ImageStreamCompleter> loader,
ImageErrorListener onError = null) {
D.assert(key != null);

}
if (_cache.TryGetValue(key, out var image)) {
// put to the MRU position
_trackLiveImage(key, new _LiveImage(image.completer, image.sizeBytes, () => _liveImages.Remove(key)));
_liveImages.TryGetValue(key, out var liveImage);
if (liveImage != null) {
_touch(key, liveImage);
return liveImage.completer;
}
_trackLiveImage(key, new _LiveImage(result, null, () => _liveImages.Remove(key)));
}
catch (Exception ex) {
if (onError != null) {

}
}
bool listenedOnce = false;
_PendingImage untrackedPendingImage = null;
if (maximumSizeBytes > 0 && imageSize > maximumSizeBytes) {
_maximumSizeBytes = imageSize + 1000;
_trackLiveImage(
key,
new _LiveImage(
result,
imageSize,
() => _liveImages.Remove(key)
),
debugPutOk: syncCall
);
_PendingImage _pendingImage = untrackedPendingImage ?? _pendingImages.getOrDefault(key);
_pendingImages.Remove(key);
if (_pendingImage != null) {
_pendingImage.removeListener();
_currentSizeBytes += imageSize;
if (_pendingImages.TryGetValue(key, out var loadedPendingImage)) {
loadedPendingImage.removeListener();
_pendingImages.Remove(key);
if (untrackedPendingImage == null) {
_touch(key, cachedImage);
D.assert(!_cache.ContainsKey(key));
_cache[key] = cachedImage;
cachedImage.node = _lruKeys.AddLast(key);
_checkCacheSize();
listenedOnce = true;
ImageStreamListener streamListener = new ImageStreamListener(listener);
_pendingImages[key] = new _PendingImage(result, listener);
result.addListener(listener);
_pendingImages[key] = new _PendingImage(result, streamListener);
}
else {
untrackedPendingImage = new _PendingImage(result, streamListener);
result.addListener(streamListener);
public ImageCacheStatus statusForKey(Object key) {
return new ImageCacheStatus(
pending: _pendingImages.ContainsKey(key),
keepAlive: _cache.ContainsKey(key),
live: _liveImages.ContainsKey(key)
);
}
bool containsKey(Object key) {
return _pendingImages[key] != null || _cache[key] != null;
}
int liveImageCount {
get => _liveImages.Count;
}
int pendingImageCount {
get => _pendingImages.Count;
}
void clearLiveImages() {
foreach (_LiveImage
image in _liveImages.Values) {
image.removeListener();
}
_liveImages.Clear();
}
while (_currentSizeBytes > _maximumSizeBytes || _cache.Count > _maximumSize) {
var node = _lruKeys.First;
var key = node.Value; // get the LRU item
Dictionary<string, object> finishArgs = new Dictionary<string, object>();
// TimelineTask checkCacheTask;
if (!foundation_.kReleaseMode) {
// checkCacheTask = TimelineTask(parent: timelineTask)..start('checkCacheSize');
finishArgs["evictedKeys"] = new List<string>();
finishArgs["currentSize"] = currentSize;
finishArgs["currentSizeBytes"] = currentSizeBytes;
}
D.assert(_cache.ContainsKey(key));
while (_currentSizeBytes > _maximumSizeBytes || _cache.Count > _maximumSize) {
object key = _cache.Keys.GetEnumerator().Current;
_currentSizeBytes -= image.sizeBytes ?? 0;
_cache.Remove(key);
if (!foundation_.kReleaseMode) {
((List<string>) finishArgs["evictedKeys"]).Add(key.ToString());
}
}
D.assert(node == image.node);
_currentSizeBytes -= image.sizeBytes;
_cache.Remove(key);
_lruKeys.Remove(image.node);
if (!foundation_.kReleaseMode) {
finishArgs["endSize"] = currentSize;
finishArgs["endSizeBytes"] = currentSizeBytes;
// checkCacheTask.finish(arguments: finishArgs);
}
D.assert(_currentSizeBytes >= 0);

}
public class ImageCacheStatus : IEquatable<ImageCacheStatus> {
internal ImageCacheStatus(
bool pending = false,
bool keepAlive = false,
bool live = false
) {
D.assert(!pending || !keepAlive);
this.pending = pending;
this.keepAlive = keepAlive;
this.live = live;
}
public bool pending;
public bool keepAlive;
public bool live;
public bool tracked {
get => pending || keepAlive || live;
}
public bool untracked {
get => !pending && !keepAlive && !live;
}
public override string ToString() =>
$"{foundation_.objectRuntimeType(this, "ImageCacheStatus")}(pending: {pending}, live: {live}, keepAlive: {keepAlive})";
public bool Equals(ImageCacheStatus other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return pending == other.pending && keepAlive == other.keepAlive && live == other.live;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((ImageCacheStatus) obj);
}
public static bool operator ==(ImageCacheStatus left, object right) {
return Equals(left, right);
}
public static bool operator !=(ImageCacheStatus left, object right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = pending.GetHashCode();
hashCode = (hashCode * 397) ^ keepAlive.GetHashCode();
hashCode = (hashCode * 397) ^ live.GetHashCode();
return hashCode;
}
}
}
public _CachedImage(ImageStreamCompleter completer, int sizeBytes) {
public _CachedImage(ImageStreamCompleter completer, int? sizeBytes) {
public int sizeBytes;
public int? sizeBytes;
class _LiveImage : _CachedImage {
internal _LiveImage(ImageStreamCompleter completer, int? sizeBytes, VoidCallback handleRemove)
: base(completer, sizeBytes) {
this.handleRemove = handleRemove;
}
public readonly VoidCallback handleRemove;
public void removeListener() {
completer.removeOnLastListenerRemovedCallback(handleRemove);
}
}
ImageListener listener
ImageStreamListener listener
) {
this.completer = completer;
this.listener = listener;

public readonly ImageListener listener;
public readonly ImageStreamListener listener;
public void removeListener() {
completer.removeListener(listener);

307
com.unity.uiwidgets/Runtime/painting/image_provider.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using Unity.UIWidgets.async2;

using UnityEngine;
using UnityEngine.Networking;
using Codec = Unity.UIWidgets.ui.Codec;
using Image = Unity.UIWidgets.ui.Image;
using Path = System.IO.Path;
using Window = Unity.UIWidgets.ui.Window;
namespace Unity.UIWidgets.painting {
public static partial class painting_ {

public abstract class ImageProvider {
public abstract ImageStream resolve(ImageConfiguration configuration);
public static bool operator !=(ImageProvider left, ImageProvider right) {
return !Equals(left, right);
}

resolveStreamForKey(configuration, stream, successKey, (Exception e) => errorHandler(e));
},
(T key, Exception exception) => {
// await null; // wait an event turn in case a listener has been added to the image stream.
_ErrorImageCompleter imageCompleter = new _ErrorImageCompleter();
stream.setCompleter(imageCompleter);
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<ImageProvider>("Image provider", this);
yield return new DiagnosticsProperty<ImageConfiguration>("Image configuration",
configuration);
yield return new DiagnosticsProperty<T>("Image key", key, defaultValue: null);
}
Timer.run(() => {
_ErrorImageCompleter imageCompleter = new _ErrorImageCompleter();
stream.setCompleter(imageCompleter);
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<ImageProvider>("Image provider", this);
yield return new DiagnosticsProperty<ImageConfiguration>("Image configuration",
configuration);
yield return new DiagnosticsProperty<T>("Image key", key, defaultValue: null);
}
collector = infoCollector;
return true;
collector = infoCollector;
return true;
});
imageCompleter.setError(
exception: exception,
stack: exception.StackTrace,
context: new ErrorDescription("while resolving an image"),
silent: true, // could be a network error or whatnot
informationCollector: collector
);
return null;
imageCompleter.setError(
exception: exception,
stack: exception.StackTrace,
context: new ErrorDescription("while resolving an image"),
silent: true, // could be a network error or whatnot
informationCollector: collector
);
return Future.value();
return null;
}
);

public ImageStream createStream(ImageConfiguration configuration) {
return new ImageStream();
}
// This is an unusual edge case where someone has told us that they found
// the image we want before getting to this method. We should avoid calling
// load again, but still update the image cache with LRU information.
if (stream.completer != null) {
ImageStreamCompleter completerEdge = PaintingBinding.instance.imageCache.putIfAbsent(
key,

return obtainKey(configuration).then(key => cache.evict(key)).to<bool>();
}
protected abstract ImageStreamCompleter load(T assetBundleImageKey, DecoderCallback decode);
public abstract ImageStreamCompleter load(T assetBundleImageKey, DecoderCallback decode);
protected abstract Future<T> obtainKey(ImageConfiguration configuration);
public abstract Future<T> obtainKey(ImageConfiguration configuration);
Future<ImageCacheStatus> obtainCacheStatus(
ImageConfiguration configuration,
ImageErrorListener handleError = null
) {
D.assert(configuration != null);
Completer completer = Completer.create();
_createErrorHandlerAndKey(
configuration,
(T key, Action<Exception> innerHandleError) => {
completer.complete(FutureOr.value(PaintingBinding.instance.imageCache.statusForKey(key)));
},
(T key, Exception exception) => {
if (handleError != null) {
handleError(exception);
}
else {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<ImageProvider>("Image provider", this);
yield return new DiagnosticsProperty<ImageConfiguration>("Image configuration",
configuration);
yield return new DiagnosticsProperty<T>("Image key", key, defaultValue: null);
}
collector = infoCollector;
return true;
});
UIWidgetsError.onError(new UIWidgetsErrorDetails(
context: new ErrorDescription("while checking the cache location of an image"),
informationCollector: collector,
exception: exception
));
completer.complete();
}
return Future.value();
}
);
return completer.future.to<ImageCacheStatus>();
}
private void _createErrorHandlerAndKey(
ImageConfiguration configuration,

didError = true;
};
// If an error is added to a synchronous completer before a listener has been
// added, it can throw an error both into the zone and up the stack. Thus, it
// looks like the error has been caught, but it is in fact also bubbling to the
// zone. Since we cannot prevent all usage of Completer.sync here, or rather
// that changing them would be too breaking, we instead hook into the same
// zone mechanism to intercept the uncaught error and deliver it to the
// image stream's error handler. Note that these errors may be duplicated,
// hence the need for the `didError` flag.
Zone dangerZone = Zone.current.fork(
specification: new ZoneSpecification(
handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone, Exception error) => {

protected AssetBundleImageProvider() {
}
protected override ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) {
public override ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) {
return new MultiFrameImageStreamCompleter(
codec: _loadAsync(key, decode),
scale: key.scale,

}
}
internal class _SizeAwareCacheKey : IEquatable<_SizeAwareCacheKey> {
internal _SizeAwareCacheKey(object providerCacheKey, int width, int height) {
this.providerCacheKey = providerCacheKey;
this.width = width;
this.height = height;
}
public readonly object providerCacheKey;
public readonly int width;
public readonly int height;
public static bool operator ==(_SizeAwareCacheKey left, object right) {
return Equals(left, right);
}
public static bool operator !=(_SizeAwareCacheKey left, object right) {
return !Equals(left, right);
}
public bool Equals(_SizeAwareCacheKey other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(providerCacheKey, other.providerCacheKey) && width == other.width && height == other.height;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((_SizeAwareCacheKey) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = (providerCacheKey != null ? providerCacheKey.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ width;
hashCode = (hashCode * 397) ^ height;
return hashCode;
}
}
}
internal class ResizeImage : ImageProvider<_SizeAwareCacheKey> {
public ResizeImage(
ImageProvider<object> imageProvider,
int width = 0,
int height = 0
) {
this.imageProvider = imageProvider;
this.width = width;
this.height = height;
}
public readonly ImageProvider<object> imageProvider;
public readonly int width;
public readonly int height;
public static ImageProvider resizeIfNeeded(int? cacheWidth, int? cacheHeight, ImageProvider provider) {
if (cacheWidth != null || cacheHeight != null) {
return new ResizeImage((ImageProvider<object>) provider, width: cacheWidth.Value,
height: cacheHeight.Value);
}
return provider;
}
public override ImageStreamCompleter load(_SizeAwareCacheKey assetBundleImageKey, DecoderCallback decode) {
Future<Codec> decodeResize(byte[] bytes, int? cacheWidth = 0, int? cacheHeight = 0) {
D.assert(
cacheWidth == null && cacheHeight == null,
() =>
"ResizeImage cannot be composed with another ImageProvider that applies cacheWidth or cacheHeight."
);
return decode(bytes, cacheWidth: width, cacheHeight: height);
}
return imageProvider.load(assetBundleImageKey.providerCacheKey, decodeResize);
}
public override Future<_SizeAwareCacheKey> obtainKey(ImageConfiguration configuration) {
Completer completer = null;
SynchronousFuture<_SizeAwareCacheKey> result = null;
imageProvider.obtainKey(configuration).then((object key) => {
// TODO: completer is always null?
if (completer == null) {
result = new SynchronousFuture<_SizeAwareCacheKey>(new _SizeAwareCacheKey(key, width, height));
}
else {
completer.complete(FutureOr.value(new _SizeAwareCacheKey(key, width, height)));
}
});
if (result != null) {
return result;
}
completer = Completer.create();
return completer.future.to<_SizeAwareCacheKey>();
}
}
public class NetworkImage : ImageProvider<NetworkImage>, IEquatable<NetworkImage> {
public NetworkImage(string url,
float scale = 1.0f,

public readonly IDictionary<string, string> headers;
protected override Future<NetworkImage> obtainKey(ImageConfiguration configuration) {
public override Future<NetworkImage> obtainKey(ImageConfiguration configuration) {
protected override ImageStreamCompleter load(NetworkImage key, DecoderCallback decode) {
public override ImageStreamCompleter load(NetworkImage key, DecoderCallback decode) {
return new MultiFrameImageStreamCompleter(
codec: _loadAsync(key, decode),
scale: key.scale,

var completer = Completer.create();
var isolate = Isolate.current;
var panel = UIWidgetsPanel.current;
panel.StartCoroutine(_loadCoroutine(key.url, completer, isolate));
return completer.future.to<byte[]>().then_<byte[]>(data => {
if (data != null && data.Length > 0) {
return decode(data);
}
throw new Exception("not loaded");
}).to<Codec>();
if (panel.IsActive()) {
panel.StartCoroutine(_loadCoroutine(key.url, completer, isolate));
return completer.future.to<byte[]>().then_<byte[]>(data => {
if (data != null && data.Length > 0) {
return decode(data);
}
throw new Exception("not loaded");
}).to<Codec>();
}
return new Future<Codec>(Future.create(() => FutureOr.value(null)));
IEnumerator _loadCoroutine(string key, Completer completer, Isolate isolate) {
var url = new Uri(key);
using (var www = UnityWebRequest.Get(url)) {

public readonly float scale;
protected override Future<FileImage> obtainKey(ImageConfiguration configuration) {
public override Future<FileImage> obtainKey(ImageConfiguration configuration) {
protected override ImageStreamCompleter load(FileImage key, DecoderCallback decode) {
public override ImageStreamCompleter load(FileImage key, DecoderCallback decode) {
return new MultiFrameImageStreamCompleter(_loadAsync(key, decode),
scale: key.scale,
informationCollector: infoCollector);

byte[] bytes = File.ReadAllBytes("Assets/StreamingAssets/" + key.file);
if (bytes != null && bytes.Length > 0 ) {
byte[] bytes = File.ReadAllBytes(Path.Combine(Application.streamingAssetsPath, key.file));
if (bytes != null && bytes.Length > 0) {
throw new Exception("not loaded");
}

}
public override string ToString() {
return $"{GetType()}(\"{file}\", scale: {scale})";
return $"{foundation_.objectRuntimeType(this, "FileImage")}({file}, scale: {scale})";
}
}

public readonly float scale;
protected override Future<MemoryImage> obtainKey(ImageConfiguration configuration) {
public override Future<MemoryImage> obtainKey(ImageConfiguration configuration) {
protected override ImageStreamCompleter load(MemoryImage key, DecoderCallback decode) {
public override ImageStreamCompleter load(MemoryImage key, DecoderCallback decode) {
return new MultiFrameImageStreamCompleter(
_loadAsync(key, decode),
scale: key.scale);

}
public override string ToString() {
return $"{GetType()}({foundation_.describeIdentity(bytes)}), scale: {scale}";
return
$"{foundation_.objectRuntimeType(this, "MemoryImage")}({foundation_.describeIdentity(bytes)}), scale: {scale}";
}
}

public readonly AssetBundle bundle;
protected override Future<AssetBundleImageKey> obtainKey(ImageConfiguration configuration) {
public override Future<AssetBundleImageKey> obtainKey(ImageConfiguration configuration) {
return Future.value(FutureOr.value(new AssetBundleImageKey(
bundle: bundle ? bundle : configuration.bundle,
name: assetName,

}
public override string ToString() {
return $"{GetType()}(name: \"{assetName}\", scale: {scale}, bundle: {bundle})";
return
$"{foundation_.objectRuntimeType(this, "ExactAssetImage")}(name: \"{assetName}\", scale: {scale}, bundle: {bundle})";
}
}

silent: silent
);
}
}
public class NetworkImageLoadException : Exception {
NetworkImageLoadException(int statusCode, Uri uri) {
D.assert(uri != null);
D.assert(statusCode != null);
this.statusCode = statusCode;
this.uri = uri;
_message = $"HTTP request failed, statusCode: {statusCode}, {uri}";
}
public readonly int statusCode;
readonly string _message;
public readonly Uri uri;
public override string ToString() => _message;
}
}

66
com.unity.uiwidgets/Runtime/painting/image_resolution.cs


using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Unity.UIWidgets.external;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;

}
public readonly string assetName;
public string keyName {
get { return package == null ? assetName : "packages/$package/$assetName"; }
}
public readonly string package;
public const float _naturalResolution = 1.0f;
protected override Future<AssetBundleImageKey> obtainKey(ImageConfiguration configuration) {
public override Future<AssetBundleImageKey> obtainKey(ImageConfiguration configuration) {
AssetImageConfiguration assetConfig = new AssetImageConfiguration(configuration, assetName);
AssetBundleImageKey key;
var cache = AssetBundleCache.instance.get(configuration.bundle);

var devicePixelRatio = configuration.devicePixelRatio ?? Window.instance.devicePixelRatio;
key = _loadAsset(chosenBundle, devicePixelRatio);
cache[assetConfig] = key;
internal string _chooseVariant(string main, ImageConfiguration config, List<string> candidates) {
if (config.devicePixelRatio == null || candidates == null || candidates.isEmpty())
return main;
SplayTree<float, string> mapping = new SplayTree<float, string>();
foreach (string candidate in candidates) {
mapping[_parseScale(candidate)] = candidate;
}
return _findNearest(mapping, config.devicePixelRatio ?? 0);
}
string _findNearest(SplayTree<float, string> candidates, float value) {
if (candidates.ContainsKey(value))
return candidates[value];
float lower = candidates.lastKeyBefore(value);
float upper = candidates.firstKeyAfter(value);
if (lower == null)
return candidates[upper];
if (upper == null)
return candidates[lower];
if (value > (lower + upper) / 2)
return candidates[upper];
else
return candidates[lower];
}
internal static readonly Regex _extractRatioRegExp = new Regex(@"/?(\d+(\.\d*)?)x$");
float _parseScale(string key) {
if (key == assetName) {
return _naturalResolution;
}
Uri assetUri = new Uri(key);
string directoryPath = "";
if (assetUri.Segments.Length > 1) {
directoryPath = assetUri.Segments[assetUri.Segments.Length - 2];
}
Match match = _extractRatioRegExp.Match(directoryPath);
if (match != null && match.Groups.Count > 0)
return float.Parse(match.Groups[1].Value);
return _naturalResolution;
}
AssetBundleImageKey _loadAsset(AssetBundle bundle, float devicePixelRatio) {
var extension = Path.GetExtension(this.assetName);
var name = Path.GetFileNameWithoutExtension(this.assetName);

Object asset;
if (bundle == null) {
asset = Resources.Load(assetName);
} else {
}
else {
asset = bundle.LoadAsset(assetName);
}

} else {
}
else {
bundle.Unload(asset);
}

}
public override string ToString() {
return $"{GetType()}(bundle: {bundle}, name: \"{assetName}\")";
return $"{foundation_.objectRuntimeType(this, "AssetImage")}(bundle: {bundle}, name: \"{assetName}\")";
}
}

198
com.unity.uiwidgets/Runtime/painting/image_stream.cs


}
}
public class ImageStreamListener : IEquatable<ImageStreamListener> {
public ImageStreamListener(
ImageListener onImage,
ImageChunkListener onChunk = null,
ImageErrorListener onError = null
) {
D.assert(onImage != null);
this.onImage = onImage;
this.onChunk = onChunk;
this.onError = onError;
}
public readonly ImageListener onImage;
public readonly ImageChunkListener onChunk;
public readonly ImageErrorListener onError;
public bool Equals(ImageStreamListener other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(onImage, other.onImage) && Equals(onChunk, other.onChunk) && Equals(onError, other.onError);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((ImageStreamListener) obj);
}
public static bool operator ==(ImageStreamListener left, ImageStreamListener right) {
return Equals(left, right);
}
public static bool operator !=(ImageStreamListener left, ImageStreamListener right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = (onImage != null ? onImage.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (onChunk != null ? onChunk.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (onError != null ? onError.GetHashCode() : 0);
return hashCode;
}
}
}
public delegate void ImageChunkListener(ImageChunkEvent evt);
class _ImageListenerPair {
public ImageListener listener;
public ImageErrorListener errorListener;
public class ImageChunkEvent : Diagnosticable {
public ImageChunkEvent(
int cumulativeBytesLoaded,
int expectedTotalBytes
) {
D.assert(cumulativeBytesLoaded >= 0);
D.assert(expectedTotalBytes >= 0);
this.cumulativeBytesLoaded = cumulativeBytesLoaded;
this.expectedTotalBytes = expectedTotalBytes;
}
public readonly int cumulativeBytesLoaded;
public readonly int expectedTotalBytes;
public override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new IntProperty("cumulativeBytesLoaded", cumulativeBytesLoaded));
properties.add(new IntProperty("expectedTotalBytes", expectedTotalBytes));
}
}
public class ImageStream : Diagnosticable {

get { return _completer; }
}
List<_ImageListenerPair> _listeners;
List<ImageStreamListener> _listeners;
public void setCompleter(ImageStreamCompleter value) {
D.assert(_completer == null);

var initialListeners = _listeners;
_listeners = null;
foreach (_ImageListenerPair listenerPair in initialListeners) {
_completer.addListener(
listenerPair.listener,
listenerPair.errorListener
);
}
initialListeners.ForEach(_completer.addListener);
public void addListener(ImageListener listener, ImageErrorListener onError = null) {
public void addListener(ImageStreamListener listener) {
_completer.addListener(listener, onError);
_completer.addListener(listener);
_listeners = new List<_ImageListenerPair>();
_listeners = new List<ImageStreamListener>();
_listeners.Add(new _ImageListenerPair {listener = listener, errorListener = onError});
_listeners.Add(listener);
public void removeListener(ImageListener listener) {
public void removeListener(ImageStreamListener listener) {
if (_completer != null) {
_completer.removeListener(listener);
return;

for (int i = 0; i < _listeners.Count; i++) {
if (_listeners[i].listener == listener) {
if (_listeners[i] == listener) {
_listeners.RemoveAt(i);
break;
}

ifPresent: _completer?.toStringShort(),
ifNull: "unresolved"
));
properties.add(new ObjectFlagProperty<List<_ImageListenerPair>>(
properties.add(new ObjectFlagProperty<List<ImageStreamListener>>(
"listeners",
_listeners,
ifPresent: $"{_listeners?.Count} listener{(_listeners?.Count == 1 ? "" : "s")}",

}
public abstract class ImageStreamCompleter : Diagnosticable {
internal readonly List<_ImageListenerPair> _listeners = new List<_ImageListenerPair>();
public ImageInfo currentImage;
public UIWidgetsErrorDetails currentError;
internal readonly List<ImageStreamListener> _listeners = new List<ImageStreamListener>();
internal ImageInfo _currentImage;
internal UIWidgetsErrorDetails _currentError;
public virtual void addListener(ImageListener listener, ImageErrorListener onError = null) {
_listeners.Add(new _ImageListenerPair {listener = listener, errorListener = onError});
if (currentImage != null) {
public virtual void addListener(ImageStreamListener listener) {
_listeners.Add(listener);
if (_currentImage != null) {
listener(currentImage, true);
listener.onImage(_currentImage, true);
catch (Exception ex) {
catch (Exception exception) {
exception: ex
exception: exception
if (currentError != null && onError != null) {
if (_currentError != null && listener.onError != null) {
onError(currentError.exception);
listener.onError(_currentError.exception);
catch (Exception ex) {
catch (Exception exception) {
exception: ex,
exception: exception,
context: new ErrorDescription("when reporting an error to an image listener")
context: new ErrorDescription("by a synchronously-called image error listener")
)
);
}

public virtual void removeListener(ImageListener listener) {
for (int i = 0; i < _listeners.Count; i++) {
if (_listeners[i].listener == listener) {
public virtual void removeListener(ImageStreamListener listener) {
for (int i = 0; i < _listeners.Count; i += 1) {
if (_listeners[i] == listener) {
if (_listeners.isEmpty()) {
foreach (VoidCallback callback in _onLastListenerRemovedCallbacks) {
callback();
}
_onLastListenerRemovedCallbacks.Clear();
}
readonly List<VoidCallback> _onLastListenerRemovedCallbacks = new List<VoidCallback>();
public void addOnLastListenerRemovedCallback(VoidCallback callback) {
D.assert(callback != null);
_onLastListenerRemovedCallbacks.Add(callback);
}
public void removeOnLastListenerRemovedCallback(VoidCallback callback) {
D.assert(callback != null);
_onLastListenerRemovedCallbacks.Remove(callback);
}
currentImage = image;
_currentImage = image;
var localListeners = _listeners.Select(l => l.listener).ToList();
var localListeners = _listeners.Select(l => l).ToList();
listener(image, false);
listener.onImage(image, false);
}
catch (Exception ex) {
reportError(

Exception exception = null,
InformationCollector informationCollector = null,
bool silent = false) {
currentError = new UIWidgetsErrorDetails(
_currentError = new UIWidgetsErrorDetails(
exception: exception,
library: "image resource service",
context: context,

var localErrorListeners = _listeners.Select(l => l.errorListener).Where(l => l != null).ToList();
var localErrorListeners = _listeners
.Select(l => l.onError)
.Where(l => l != null)
.ToList();
UIWidgetsError.reportError(currentError);
UIWidgetsError.reportError(_currentError);
}
else {
foreach (var errorListener in localErrorListeners) {

public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<ImageInfo>(
"current", currentImage, ifNull: "unresolved", showName: false));
description.add(new ObjectFlagProperty<List<_ImageListenerPair>>(
"current", _currentImage, ifNull: "unresolved", showName: false));
description.add(new ObjectFlagProperty<List<ImageStreamListener>>(
"listeners",
_listeners,
ifPresent: $"{_listeners.Count} listener{(_listeners.Count == 1 ? "" : "s")}"

}
}
// TODO: update stream
public class MultiFrameImageStreamCompleter : ImageStreamCompleter {
public MultiFrameImageStreamCompleter(
Future<Codec> codec,

TimeSpan delay = _frameDuration.Value - (timestamp - _shownTimestamp.Value);
delay = new TimeSpan((long) (delay.Ticks * scheduler_.timeDilation));
// TODO: time dilation
_timer = Timer.create(delay , ()=> _scheduleAppFrame());
_timer = Timer.create(delay, () => _scheduleAppFrame());
}
bool _isFirstFrame() {

_framesEmitted += 1;
}
public override void addListener(ImageListener listener, ImageErrorListener onError = null) {
public override void addListener(ImageStreamListener listener) {
base.addListener(listener, onError: onError);
base.addListener(listener);
public override void removeListener(ImageListener listener) {
public override void removeListener(ImageStreamListener listener) {
base.removeListener(listener);
if (!hasListeners) {
_timer?.cancel();

15
com.unity.uiwidgets/Runtime/painting/inline_span.cs


public abstract class InlineSpan : DiagnosticableTree, IEquatable<InlineSpan> {
public InlineSpan(
TextStyle style = null
TextStyle style = null
public abstract void build(ParagraphBuilder builder,
float textScaleFactor = 1, List<PlaceholderDimensions> dimensions = null
);

public virtual string toPlainText(
bool includeSemanticsLabels = true,
bool includePlaceholders = true)
{
bool includePlaceholders = true) {
StringBuilder buffer = new StringBuilder();
computeToPlainText(buffer, includeSemanticsLabels: includeSemanticsLabels,
includePlaceholders: includePlaceholders);

public abstract void computeToPlainText(
StringBuilder buffer,
bool includeSemanticsLabels = true,
bool includeSemanticsLabels = true,
bool includePlaceholders = true);
public int? codeUnitAt(int index) {

public virtual bool debugAssertIsValid() => true;
public abstract RenderComparison compareTo(InlineSpan other);
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
public virtual void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace;
if (style != null) {

public override int GetHashCode() {
return (style != null ? style.GetHashCode() : 0);
}
public static bool operator ==(InlineSpan left, InlineSpan right) {
return Equals(left, right);
}

220
com.unity.uiwidgets/Runtime/painting/matrix_utils.cs


public static float dot(this Vector3 left, Vector3 right) {
return left.x * right.x + left.y * right.y + left.z * right.z;
}
public static Offset getAsTranslation(this Matrix4 values) {
if (values[0] == 1 && // col 1
values[1] == 0 &&

return null;
}
}
q.w = Mathf.Sqrt( Mathf.Max( 0, 1 + m.entry(0,0) + m.entry(1,1) + m.entry(2,2) ) ) / 2;
q.x = Mathf.Sqrt( Mathf.Max( 0, 1 + m.entry(0,0) - m.entry(1,1) - m.entry(2,2) ) ) / 2;
q.y = Mathf.Sqrt( Mathf.Max( 0, 1 - m.entry(0,0) + m.entry(1,1) - m.entry(2,2) ) ) / 2;
q.z = Mathf.Sqrt( Mathf.Max( 0, 1 - m.entry(0,0) - m.entry(1,1) + m.entry(2,2) ) ) / 2;
q.x *= Mathf.Sign( q.x * ( m.entry(2,1) - m.entry(1,2) ) );
q.y *= Mathf.Sign( q.y * ( m.entry(0,2) - m.entry(2,0) ) );
q.z *= Mathf.Sign( q.z * ( m.entry(1,0) - m.entry(0,1) ) );
q.w = Mathf.Sqrt(Mathf.Max(0, 1 + m.entry(0, 0) + m.entry(1, 1) + m.entry(2, 2))) / 2;
q.x = Mathf.Sqrt(Mathf.Max(0, 1 + m.entry(0, 0) - m.entry(1, 1) - m.entry(2, 2))) / 2;
q.y = Mathf.Sqrt(Mathf.Max(0, 1 - m.entry(0, 0) + m.entry(1, 1) - m.entry(2, 2))) / 2;
q.z = Mathf.Sqrt(Mathf.Max(0, 1 - m.entry(0, 0) - m.entry(1, 1) + m.entry(2, 2))) / 2;
q.x *= Mathf.Sign(q.x * (m.entry(2, 1) - m.entry(1, 2)));
q.y *= Mathf.Sign(q.y * (m.entry(0, 2) - m.entry(2, 0)));
q.z *= Mathf.Sign(q.z * (m.entry(1, 0) - m.entry(0, 1)));
}
public static Quaternion scaled(this Quaternion lhs, float scale) {

lhs.w *= scale;
return lhs;
}
public static Quaternion add(this Quaternion lhs, Quaternion rhs) {
lhs.x += rhs.x;
lhs.y += rhs.y;

return new List<string> {"null"};
}
List<string> result = new List<string>(3);
List<string> result = new List<string>(){
$"[0] ${D.debugFormatFloat(transform.entry(0, 0))},${D.debugFormatFloat(transform.entry(0, 1))},${D.debugFormatFloat(transform.entry(0, 2))},${D.debugFormatFloat(transform.entry(0, 3))}",
$"[1] ${D.debugFormatFloat(transform.entry(1, 0))},${D.debugFormatFloat(transform.entry(1, 1))},${D.debugFormatFloat(transform.entry(1, 2))},${D.debugFormatFloat(transform.entry(1, 3))}",
$"[2] ${D.debugFormatFloat(transform.entry(2, 0))},${D.debugFormatFloat(transform.entry(2, 1))},${D.debugFormatFloat(transform.entry(2, 2))},${D.debugFormatFloat(transform.entry(2, 3))}",
$"[3] ${D.debugFormatFloat(transform.entry(3, 0))},${D.debugFormatFloat(transform.entry(3, 1))},${D.debugFormatFloat(transform.entry(3, 2))},${D.debugFormatFloat(transform.entry(3, 3))}"
};
for (int i = 0; i < 3; i++) {
result.Add($"[{i}] {transform[i * 3]}, {transform[i * 3 + 1]}, {transform[i * 3 + 2]}");
}

public static Offset transformPoint(Matrix4 transform, Offset point) {
Vector3 position3 = new Vector3(point.dx, point.dy, 0);
Vector3 transformed3 = transform.perspectiveTransform(position3);
return new Offset(transformed3.x, transformed3.y);
float[] storage = transform.storage;
float x = point.dx;
float y = point.dy;
float rx = storage[0] * x + storage[4] * y + storage[12];
float ry = storage[1] * x + storage[5] * y + storage[13];
float rw = storage[3] * x + storage[7] * y + storage[15];
if (rw == 1.0f) {
return new Offset(rx, ry);
}
else {
return new Offset(rx / rw, ry / rw);
}
}
internal static Rect _safeTransformRect(Matrix4 transform, Rect rect) {
float[] storage = transform.storage;
bool isAffine = storage[3] == 0.0 &&
storage[7] == 0.0 &&
storage[15] == 1.0;
_minMax = _minMax ?? new float[4];
_accumulate(storage, rect.left, rect.top, true, isAffine);
_accumulate(storage, rect.right, rect.top, false, isAffine);
_accumulate(storage, rect.left, rect.bottom, false, isAffine);
_accumulate(storage, rect.right, rect.bottom, false, isAffine);
return Rect.fromLTRB(_minMax[0], _minMax[1], _minMax[2], _minMax[3]);
}
static float[] _minMax;
static void _accumulate(float[] m, float x, float y, bool first, bool isAffine) {
float w = isAffine ? 1.0f : 1.0f / (m[3] * x + m[7] * y + m[15]);
float tx = (m[0] * x + m[4] * y + m[12]) * w;
float ty = (m[1] * x + m[5] * y + m[13]) * w;
if (first) {
_minMax[0] = _minMax[2] = tx;
_minMax[1] = _minMax[3] = ty;
}
else {
if (tx < _minMax[0]) {
_minMax[0] = tx;
}
if (ty < _minMax[1]) {
_minMax[1] = ty;
}
if (tx > _minMax[2]) {
_minMax[2] = tx;
}
if (ty > _minMax[3]) {
_minMax[3] = ty;
}
}
Offset point1 = transformPoint(transform, rect.topLeft);
Offset point2 = transformPoint(transform, rect.topRight);
Offset point3 = transformPoint(transform, rect.bottomLeft);
Offset point4 = transformPoint(transform, rect.bottomRight);
return Rect.fromLTRB(
_min4(point1.dx, point2.dx, point3.dx, point4.dx),
_min4(point1.dy, point2.dy, point3.dy, point4.dy),
_max4(point1.dx, point2.dx, point3.dx, point4.dx),
_max4(point1.dy, point2.dy, point3.dy, point4.dy)
);
float[] storage = transform.storage;
float x = rect.left;
float y = rect.top;
float w = rect.right - x;
float h = rect.bottom - y;
if (!w.isFinite() || !h.isFinite()) {
return _safeTransformRect(transform, rect);
}
float wx = storage[0] * w;
float hx = storage[4] * h;
float rx = storage[0] * x + storage[4] * y + storage[12];
float wy = storage[1] * w;
float hy = storage[5] * h;
float ry = storage[1] * x + storage[5] * y + storage[13];
if (storage[3] == 0.0f && storage[7] == 0.0f && storage[15] == 1.0f) {
float left = rx;
float right = rx;
if (wx < 0) {
left += wx;
}
else {
right += wx;
}
if (hx < 0) {
left += hx;
}
else {
right += hx;
}
float top = ry;
float bottom = ry;
if (wy < 0) {
top += wy;
}
else {
bottom += wy;
}
if (hy < 0) {
top += hy;
}
else {
bottom += hy;
}
return Rect.fromLTRB(left, top, right, bottom);
}
else {
float ww = storage[3] * w;
float hw = storage[7] * h;
float rw = storage[3] * x + storage[7] * y + storage[15];
float ulx = rx / rw;
float uly = ry / rw;
float urx = (rx + wx) / (rw + ww);
float ury = (ry + wy) / (rw + ww);
float llx = (rx + hx) / (rw + hw);
float lly = (ry + hy) / (rw + hw);
float lrx = (rx + wx + hx) / (rw + ww + hw);
float lry = (ry + wy + hy) / (rw + ww + hw);
return Rect.fromLTRB(
_min4(ulx, urx, llx, lrx),
_min4(uly, ury, lly, lry),
_max4(ulx, urx, llx, lrx),
_max4(uly, ury, lly, lry)
);
}
}
static bool isIdentity(Matrix4 a) {

&& a[14] == 0.0
&& a[15] == 1.0;
}
public static Rect inverseTransformRect(Matrix4 transform, Rect rect) {
D.assert(rect != null);
D.assert(transform.determinant() != 0.0);

return transformRect(transform, rect);
}
return Mathf.Min(a, Mathf.Min(b, Mathf.Min(c, d)));
float e = (a < b) ? a : b;
float f = (c < d) ? c : d;
return (e < f) ? e : f;
return Mathf.Max(a, Mathf.Max(b, Mathf.Max(c, d)));
float e = (a > b) ? a : b;
float f = (c > d) ? c : d;
return (e > f) ? e : f;
}
static Matrix4 createCylindricalProjectionTransform(
float radius,
float angle,
float perspective = 0.001f,
Axis? orientation = null
) {
D.assert(perspective >= 0 && perspective <= 1.0);
if (orientation == null) {
orientation = Axis.vertical;
}
Matrix4 result = Matrix4.identity();
result.setEntry(3, 2, -perspective);
result.setEntry(2, 3, -radius);
result.setEntry(3, 3, perspective * radius + 1.0f);
result = result * ((
orientation == Axis.horizontal
? Matrix4.rotationY(angle)
: Matrix4.rotationX(angle)
) * Matrix4.translationValues(0.0f, 0.0f, radius)) as Matrix4;
return result;
}
static Matrix4 forceToPoint(Offset offset) {
var result = Matrix4.identity();
result.setRow(0, new Vector4(0, 0, 0, offset.dx));
result.setRow(1, new Vector4(0, 0, 0, offset.dy));
return result;
}
}

object defaultValue = null,
DiagnosticLevel level = DiagnosticLevel.info
) : base(name, value, showName: showName, defaultValue: defaultValue ?? foundation_.kNoDefaultValue,
level: level) { }
level: level) {
}
protected override string valueToString(TextTreeConfiguration parentConfiguration = null) {
if (parentConfiguration != null && !parentConfiguration.lineBreakProperties) {

40
com.unity.uiwidgets/Runtime/painting/rounded_rectangle_border.cs


public readonly BorderRadius borderRadius;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get { return EdgeInsets.all(side.width); }
}

borderRadius: borderRadius * t
borderRadius: (BorderRadius) (borderRadius * t)
);
}

return base.lerpTo(b, t);
}
public override Path getInnerPath(Rect rect) {
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
path.addRRect(borderRadius.toRRect(rect).deflate(side.width));
path.addRRect(borderRadius.resolve(textDirection).toRRect(rect).deflate(side.width));
public override Path getOuterPath(Rect rect) {
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
path.addRRect(borderRadius.toRRect(rect));
path.addRRect(borderRadius.resolve(textDirection).toRRect(rect));
public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null) {
switch (side.style) {
case BorderStyle.none:
break;

canvas.drawRRect(borderRadius.toRRect(rect), side.toPaint());
canvas.drawRRect(borderRadius.resolve(textDirection).toRRect(rect), side.toPaint());
RRect outer = borderRadius.toRRect(rect);
RRect outer = borderRadius.resolve(textDirection).toRRect(rect);
RRect inner = outer.deflate(width);
Paint paint = new Paint {
color = side.color,

public readonly float circleness;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get { return EdgeInsets.all(side.width); }
}

borderRadius: borderRadius * t,
borderRadius: (BorderRadius) (borderRadius * t),
circleness: t
);
}

}
}
BorderRadius _adjustBorderRadius(Rect rect) {
BorderRadius resolvedRadius = borderRadius;
BorderRadius _adjustBorderRadius(Rect rect, TextDirection? textDirection) {
BorderRadius resolvedRadius = borderRadius.resolve(textDirection);
if (circleness == 0.0f) {
return resolvedRadius;
}

public override Path getInnerPath(Rect rect) {
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
path.addRRect(_adjustBorderRadius(rect).toRRect(_adjustRect(rect)).deflate(side.width));
path.addRRect(_adjustBorderRadius(rect, textDirection).toRRect(_adjustRect(rect)).deflate(side.width));
public override Path getOuterPath(Rect rect) {
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
path.addRRect(_adjustBorderRadius(rect).toRRect(_adjustRect(rect)));
path.addRRect(_adjustBorderRadius(rect, textDirection).toRRect(_adjustRect(rect)));
public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null) {
switch (side.style) {
case BorderStyle.none:
break;

canvas.drawRRect(_adjustBorderRadius(rect).toRRect(_adjustRect(rect)),
canvas.drawRRect(_adjustBorderRadius(rect, textDirection).toRRect(_adjustRect(rect)),
RRect outer = _adjustBorderRadius(rect).toRRect(_adjustRect(rect));
RRect outer = _adjustBorderRadius(rect, textDirection).toRRect(_adjustRect(rect));
RRect inner = outer.deflate(width);
Paint paint = new Paint {
color = side.color,

9
com.unity.uiwidgets/Runtime/painting/shape_decoration.cs


public override Path getClipPath(Rect rect, TextDirection textDirection) {
return shape.getOuterPath(rect);
}
public override EdgeInsets padding {
public override EdgeInsetsGeometry padding {
get { return shape.dimensions; }
}

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace;
properties.add(new DiagnosticsProperty<Color>("color", color,
properties.add(new ColorProperty("color", color,
defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<Gradient>("gradient", gradient,
defaultValue: foundation_.kNullDefaultValue));

D.assert(configuration != null);
D.assert(configuration.size != null);
Rect rect = offset & configuration.size;
TextDirection textDirection = configuration.textDirection;
_decoration.shape.paint(canvas, rect);
_decoration.shape.paint(canvas, rect, textDirection: textDirection);
}
}
}

31
com.unity.uiwidgets/Runtime/painting/stadium_border.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting {

public readonly BorderSide side;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get { return EdgeInsets.all(side.width); }
}

return base.lerpTo(b, t);
}
public override Path getInnerPath(Rect rect) {
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
Radius radius = Radius.circular(rect.shortestSide / 2.0f);
var path = new Path();
path.addRRect(RRect.fromRectAndRadius(rect, radius).deflate(side.width));

public override Path getOuterPath(Rect rect) {
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
Radius radius = Radius.circular(rect.shortestSide / 2.0f);
var path = new Path();
path.addRRect(RRect.fromRectAndRadius(rect, radius));

public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null) {
switch (side.style) {
case BorderStyle.none:
break;

}
public override string ToString() {
return $"{GetType()}({side})";
return $"{foundation_.objectRuntimeType(this, "StadiumBorder")}({side})";
}
}

public readonly float circleness;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get { return EdgeInsets.all(side.width); }
}

return BorderRadius.circular(rect.shortestSide / 2.0f);
}
public override Path getInnerPath(Rect rect) {
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
public override Path getOuterPath(Rect rect) {
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null) {
switch (side.style) {
case BorderStyle.none:
break;

}
public override string ToString() {
return $"StadiumBorder($side, {circleness * 100:F1}% " +
return $"StadiumBorder({side}, {circleness * 100:F1}% " +
"of the way to being a CircleBorder)";
}
}

public readonly float rectness;
public override EdgeInsets dimensions {
public override EdgeInsetsGeometry dimensions {
get { return EdgeInsets.all(side.width); }
}

borderRadius: borderRadius * t,
borderRadius: (BorderRadius) (borderRadius * t),
rectness: t
);
}

);
}
public override Path getInnerPath(Rect rect) {
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null) {
public override Path getOuterPath(Rect rect) {
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null) {
public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null) {
switch (side.style) {
case BorderStyle.none:
break;

29
com.unity.uiwidgets/Runtime/painting/strut_style.cs


}
public override string toStringShort() {
return $"{GetType()}";
return $"{foundation_.objectRuntimeType(this, "StrutStyle")}";
debugFillProperties(properties, "");
}
public void debugFillProperties(DiagnosticPropertiesBuilder properties, string prefix = "") {
properties.add(new MessageProperty("debugLabel", debugLabel));
properties.add(new MessageProperty($"{prefix}debugLabel", debugLabel));
styles.Add(new StringProperty("family", fontFamily, defaultValue: foundation_.kNullDefaultValue,
styles.Add(new StringProperty($"{prefix}family", fontFamily, defaultValue: foundation_.kNullDefaultValue,
styles.Add(new EnumerableProperty<string>("familyFallback", fontFamilyFallback));
styles.Add(new DiagnosticsProperty<float?>("size", fontSize,
styles.Add(new EnumerableProperty<string>($"{prefix}familyFallback", fontFamilyFallback));
styles.Add(new DiagnosticsProperty<float?>($"{prefix}size", fontSize,
defaultValue: foundation_.kNullDefaultValue));
string weightDescription = "";
if (fontWeight != null) {

styles.Add(new DiagnosticsProperty<FontWeight>(
"weight", fontWeight,
$"{prefix}weight", fontWeight,
styles.Add(new EnumProperty<FontStyle?>("style", fontStyle,
styles.Add(new EnumProperty<FontStyle?>($"{prefix}style", fontStyle,
styles.Add(new DiagnosticsProperty<float?>("height", height,
defaultValue: foundation_.kNullDefaultValue));
styles.Add(new FlagProperty("forceStrutHeight", value: forceStrutHeight,
styles.Add(new DiagnosticsProperty<float?>($"{prefix}height", height,
styles.Add(new FlagProperty($"{prefix}forceStrutHeight", value: forceStrutHeight,
defaultValue: foundation_.kNullDefaultValue, ifTrue: $"{prefix}<strut height forced>",
ifFalse: $"{prefix}<strut height normal>"));
bool styleSpecified = styles.Any((DiagnosticsNode n) => !n.isFiltered(DiagnosticLevel.info));
foreach (var style in styles) {

if (!styleSpecified) {
properties.add(new FlagProperty("forceStrutHeight", value: forceStrutHeight,
ifTrue: "<strut height forced>",
ifFalse: "<strut height normal>"));
ifTrue: $"{prefix}<strut height forced>",
ifFalse: $"{prefix}<strut height normal>"));
}
}
}

34
com.unity.uiwidgets/Runtime/painting/text_painter.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;

markNeedsLayout();
}
}
get {
return _locale;
}
get { return _locale; }
set {
if (_locale == value)
return;

}
public TextWidthBasis textWidthBasis {
get { return _textWidthBasis; }
set {

}
void setPlaceholderDimensions(List<PlaceholderDimensions> value) {
if (value == null || value.isEmpty() || value.SequenceEqual(_placeholderDimensions)) {
if (value == null || value.isEmpty() || value.equalsList(_placeholderDimensions)) {
return;
}

_paragraph.layout(new ParagraphConstraints(newWidth));
}
}
_inlinePlaceholderBoxes = _paragraph.getBoxesForPlaceholders();
}

BoxHeightStyle boxHeightStyle = BoxHeightStyle.tight,
BoxWidthStyle boxWidthStyle = BoxWidthStyle.tight) {
D.assert(!_needsLayout);
var results = _paragraph.getBoxesForRange(selection.start, selection.end, boxHeightStyle: boxHeightStyle,
var results = _paragraph.getBoxesForRange(
selection.start,
selection.end,
boxHeightStyle: boxHeightStyle,
boxWidthStyle: boxWidthStyle);
return results;
}

D.assert(!_needsLayout);
return _paragraph.getLineBoundary(position);
}
List<ui.LineMetrics> computeLineMetrics() {
D.assert(!_needsLayout);
return _paragraph.computeLineMetrics();
}
ParagraphStyle _createParagraphStyle(TextDirection defaultTextDirection = TextDirection.ltr) {
D.assert(textAlign != null);

textDirection: textDirection ?? defaultTextDirection,
textScaleFactor: textScaleFactor,
maxLines: _maxLines,
// textHeightBehavior: _textHeightBehavior,
ellipsis: _ellipsis
// locale: _locale,
// strutStyle: _strutStyle,
textHeightBehavior: _textHeightBehavior,
ellipsis: _ellipsis,
locale: _locale,
strutStyle: _strutStyle
ellipsis: ellipsis
// locale: locale,
ellipsis: ellipsis,
locale: locale
);
}

2
com.unity.uiwidgets/Runtime/painting/text_span.cs


}
public override string toStringShort() {
return GetType().ToString();
return foundation_.objectRuntimeType(this, "TextSpan");
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

167
com.unity.uiwidgets/Runtime/painting/text_style.cs


}
public RenderComparison compareTo(TextStyle other) {
if (inherit != other.inherit || fontFamily != other.fontFamily ||
fontSize != other.fontSize || fontWeight != other.fontWeight ||
fontStyle != other.fontStyle || letterSpacing != other.letterSpacing ||
wordSpacing != other.wordSpacing || textBaseline != other.textBaseline ||
height != other.height || background != other.background ||
shadows.equalsList(other.shadows) || fontFeatures.equalsList(other.fontFeatures)) {
if (ReferenceEquals(this, other))
return RenderComparison.identical;
if (inherit != other.inherit ||
fontFamily != other.fontFamily ||
fontSize != other.fontSize ||
fontWeight != other.fontWeight ||
fontStyle != other.fontStyle ||
letterSpacing != other.letterSpacing ||
wordSpacing != other.wordSpacing ||
textBaseline != other.textBaseline ||
height != other.height ||
foreground != other.foreground ||
background != other.background ||
!shadows.equalsList(other.shadows) ||
!fontFeatures.equalsList(other.fontFeatures) ||
!fontFamilyFallback.equalsList(other.fontFamilyFallback)) {
if (color != other.color || decoration != other.decoration ||
if (color != other.color ||
backgroundColor != other.backgroundColor ||
decoration != other.decoration ||
decorationColor != other.decorationColor ||
decorationStyle != other.decorationStyle) {
return RenderComparison.paint;

}
public ParagraphStyle getParagraphStyle(TextAlign textAlign,
TextDirection textDirection, string ellipsis, int? maxLines,
public ParagraphStyle getParagraphStyle(
TextAlign textAlign,
TextDirection textDirection,
float? textScaleFactor = 1.0f,
string ellipsis = null,
int? maxLines = null,
float textScaleFactor = 1.0f) {
return new ParagraphStyle(
Locale locale = null,
String fontFamily = null,
float? fontSize = null,
FontWeight fontWeight = null,
FontStyle? fontStyle = null,
float? height = null,
StrutStyle strutStyle = null
) {
D.assert(textScaleFactor != null);
D.assert(maxLines == null || maxLines > 0);
return new ui.ParagraphStyle(
fontWeight: fontWeight,
fontStyle: fontStyle,
maxLines: maxLines,
fontSize: (fontSize ?? _defaultFontSize) * textScaleFactor,
fontFamily: fontFamily,
height: height,
fontWeight: fontWeight ?? this.fontWeight,
fontStyle: fontStyle ?? this.fontStyle,
fontFamily: fontFamily ?? this.fontFamily,
fontSize: (fontSize ?? this.fontSize ?? _defaultFontSize) * textScaleFactor,
height: height ?? this.height,
ellipsis: ellipsis
strutStyle: strutStyle == null
? null
: new ui.StrutStyle(
fontFamily: strutStyle.fontFamily,
fontFamilyFallback: strutStyle.fontFamilyFallback,
fontSize: strutStyle.fontSize == null ? null : strutStyle.fontSize * textScaleFactor,
height: strutStyle.height,
leading: strutStyle.leading,
fontWeight: strutStyle.fontWeight,
fontStyle: strutStyle.fontStyle,
forceStrutHeight: strutStyle.forceStrutHeight
),
maxLines: maxLines,
ellipsis: ellipsis,
locale: locale
);
}

decorationThickness: decorationThickness == null
? null
: decorationThickness * decorationThicknessFactor + decorationThicknessDelta,
shadows: shadows ?? this.shadows,
shadows: shadows ?? this.shadows,
fontFeatures: fontFeatures,
debugLabel: modifiedDebugLabel
);

return new TextStyle(
inherit: inherit ?? this.inherit,
color: this.foreground == null && foreground == null ? color ?? this.color : null,
backgroundColor: this.background == null && background == null ? color ?? this.color : null,
backgroundColor: this.background == null && background == null ? backgroundColor ?? this.backgroundColor : null,
fontFamily: fontFamily ?? this.fontFamily,
fontFamilyFallback: fontFamilyFallback ?? this.fontFamilyFallback,
fontSize: fontSize ?? this.fontSize,

);
}
ui.ParagraphStyle getParagraphStyle(
TextAlign? textAlign = null,
TextDirection? textDirection = null,
float textScaleFactor = 1.0f,
String ellipsis = null,
int? maxLines = null,
ui.TextHeightBehavior textHeightBehavior = null,
Locale locale = null,
String fontFamily = null,
float? fontSize = null,
FontWeight fontWeight = null,
FontStyle? fontStyle = null,
float? height = null,
StrutStyle strutStyle = null
) {
D.assert(maxLines == null || maxLines > 0);
return new ui.ParagraphStyle(
textAlign: textAlign,
textDirection: textDirection,
fontWeight: fontWeight ?? this.fontWeight,
fontStyle: fontStyle ?? this.fontStyle,
fontFamily: fontFamily ?? this.fontFamily,
fontSize: (fontSize ?? this.fontSize ?? _defaultFontSize) * textScaleFactor,
height: height ?? this.height,
textHeightBehavior: textHeightBehavior,
strutStyle: strutStyle == null
? null
: new ui.StrutStyle(
fontFamily: strutStyle.fontFamily,
fontFamilyFallback: strutStyle.fontFamilyFallback,
fontSize: strutStyle.fontSize == null ? null : strutStyle.fontSize * textScaleFactor,
height: strutStyle.height,
leading: strutStyle.leading,
fontWeight: strutStyle.fontWeight,
fontStyle: strutStyle.fontStyle,
forceStrutHeight: strutStyle.forceStrutHeight
),
maxLines: maxLines,
ellipsis: ellipsis,
locale: locale
);
}
public ui.TextStyle getTextStyle(float textScaleFactor = 1.0f) {
var backgroundPaint = new Paint();
if (background != null) {

);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
debugFillProperties(properties, "");
}
public void debugFillProperties(DiagnosticPropertiesBuilder properties, string prefix = "") {
styles.Add(new DiagnosticsProperty<Color>("color", color,
styles.Add(new ColorProperty($"{prefix}color", color,
styles.Add(new DiagnosticsProperty<Color>("backgroundColor", backgroundColor,
styles.Add(new ColorProperty($"{prefix}backgroundColor", backgroundColor,
styles.Add(new StringProperty("family", fontFamily, defaultValue: foundation_.kNullDefaultValue,
styles.Add(new StringProperty($"{prefix}family", fontFamily, defaultValue: foundation_.kNullDefaultValue,
styles.Add(new EnumerableProperty<string>("familyFallback", fontFamilyFallback,
styles.Add(new EnumerableProperty<string>($"{prefix}familyFallback", fontFamilyFallback,
styles.Add(new DiagnosticsProperty<float?>("size", fontSize,
styles.Add(new DiagnosticsProperty<float?>($"{prefix}size", fontSize,
defaultValue: foundation_.kNullDefaultValue));
string weightDescription = "";
if (fontWeight != null) {

description: weightDescription,
defaultValue: foundation_.kNullDefaultValue
));
styles.Add(new EnumProperty<FontStyle?>("style", fontStyle,
styles.Add(new EnumProperty<FontStyle?>($"{prefix}style", fontStyle,
styles.Add(new DiagnosticsProperty<float?>("letterSpacing", letterSpacing,
styles.Add(new DiagnosticsProperty<float?>($"{prefix}letterSpacing", letterSpacing,
styles.Add(new DiagnosticsProperty<float?>("wordSpacing", wordSpacing,
styles.Add(new DiagnosticsProperty<float?>($"{prefix}wordSpacing", wordSpacing,
styles.Add(new EnumProperty<TextBaseline?>("baseline", textBaseline,
styles.Add(new EnumProperty<TextBaseline?>($"{prefix}baseline", textBaseline,
styles.Add(new DiagnosticsProperty<float?>("height", height,
styles.Add(new DiagnosticsProperty<float?>($"{prefix}height", height,
styles.Add(new StringProperty("foreground", foreground == null ? null : foreground.ToString(),
styles.Add(new StringProperty($"{prefix}foreground", foreground == null ? null : foreground.ToString(),
styles.Add(new StringProperty("background", background == null ? null : background.ToString(),
styles.Add(new StringProperty($"{prefix}background", background == null ? null : background.ToString(),
defaultValue: foundation_.kNullDefaultValue, quoted: false));
if (decoration != null) {
List<string> decorationDescription = new List<string>();

styles.Add(new DiagnosticsProperty<Color>("decorationColor", decorationColor,
styles.Add(new ColorProperty($"{prefix}decorationColor", decorationColor,
defaultValue: foundation_.kNullDefaultValue,
level: DiagnosticLevel.fine));
if (decorationColor != null) {

styles.Add(new DiagnosticsProperty<TextDecoration>("decoration", decoration,
styles.Add(new DiagnosticsProperty<TextDecoration>($"{prefix}decoration", decoration,
decorationDescription.Add("$decoration");
decorationDescription.Add($"{decoration}");
styles.Add(new MessageProperty("decoration", string.Join(" ", decorationDescription.ToArray())));
styles.Add(new FloatProperty("decorationThickness", decorationThickness, unit: "x",
styles.Add(new MessageProperty($"{prefix}decoration", string.Join(" ", decorationDescription.ToArray())));
styles.Add(new FloatProperty($"{prefix}decorationThickness", decorationThickness, unit: "x",
defaultValue: foundation_.kNoDefaultValue));
}

}
if (!styleSpecified) {
properties.add(new FlagProperty("inherit", value: inherit, ifTrue: "<all styles inherited>",
ifFalse: "<no style specified>"));
properties.add(new FlagProperty("inherit", value: inherit, ifTrue: $"{prefix}<all styles inherited>",
ifFalse: $"{prefix}<no style specified>"));
}
}

Equals(background, other.background) &&
fontFamilyFallback.equalsList(other.fontFamilyFallback) &&
shadows.equalsList(other.shadows) &&
fontFeatures.equalsList(other.fontFeatures) &&
fontFeatures.equalsList(other.fontFeatures) &&
string.Equals(fontFamily, other.fontFamily);
}

8
com.unity.uiwidgets/Runtime/rendering/binding.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.scheduler2;
public class RendererBinding : PaintingBinding {
public class RendererBinding : SchedulerBinding {
get { return (RendererBinding) PaintingBinding.instance; }
set { PaintingBinding.instance = value; }
get { return (RendererBinding) SchedulerBinding.instance; }
set { Window.instance._binding = value; }
}
protected override void initInstances() {

2
com.unity.uiwidgets/Runtime/rendering/image.cs


return;
}
ImageUtils.paintImage(
painting_.paintImage(
canvas: context.canvas,
rect: offset & size,
image: _image,

2
com.unity.uiwidgets/Runtime/rendering/proxy_box.cs


public void rotateX(float degrees) {
_transform.rotateX(degrees);
markNeedsPaint();
//2D, do nothing
//2D, do nothing
}
public void rotateZ(float degrees) {

4
com.unity.uiwidgets/Runtime/scheduler2/binding.cs


using Unity.UIWidgets.async;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using UnityEditor.PackageManager;
using UnityEngine;
using FrameTiming = Unity.UIWidgets.ui.FrameTiming;
using Timer = Unity.UIWidgets.async2.Timer;

postFrameCallbacks,
}
public class SchedulerBinding : BindingBase {
public class SchedulerBinding : PaintingBinding {
protected override void initInstances() {
base.initInstances();
instance = this;

3
com.unity.uiwidgets/Runtime/services/binding.cs


using System.Collections.Generic;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
public class ServicesBinding : BindingBase {
public class ServicesBinding : GestureBinding {
protected override void initInstances() {
base.initInstances();
instance = this;

22
com.unity.uiwidgets/Runtime/ui2/window.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using UnityEngine.UI;
namespace Unity.UIWidgets.ui {
public delegate void VoidCallback();

}
}
protected float queryDevicePixelRatio() {
return _panel.devicePixelRatioOverride;
}
D.assert(false, () => "window.windowPosToScreenPos is not implemented yet!");
return offset;
Camera camera = null;
var canvas = _panel.canvas;
if (canvas.renderMode != RenderMode.ScreenSpaceCamera) {
camera = canvas.GetComponent<GraphicRaycaster>().eventCamera;
}
var pos = new Vector2(offset.dx, offset.dy);
pos = pos * queryDevicePixelRatio() / _panel.canvas.scaleFactor;
var rectTransform = _panel.rectTransform;
var rect = rectTransform.rect;
pos.x += rect.min.x;
pos.y = rect.max.y - pos.y;
var worldPos = rectTransform.TransformPoint(new Vector2(pos.x, pos.y));
var screenPos = RectTransformUtility.WorldToScreenPoint(camera, worldPos);
return new Offset(screenPos.x, Screen.height - screenPos.y);
}
public void run(Action callback) {

1
com.unity.uiwidgets/Runtime/widgets/app.cs


routes = routes ?? new Dictionary<string, WidgetBuilder>();
supportedLocales = supportedLocales ?? new List<Locale> {new Locale("en", "US")};
window = Window.instance;
D.assert(navigatorObservers != null);
D.assert(routes != null);
this.home = home;
this.navigatorKey = navigatorKey;

1
com.unity.uiwidgets/Runtime/widgets/basic.cs


/// The [color] parameter must not be null.
public ColoredBox(Color color = null, Widget child = null, Key key = null) : base(key: key, child: child) {
D.assert(color != null);
this.color = color;
}
/// The color to paint the background area with.
public readonly Color color;

9
com.unity.uiwidgets/Runtime/widgets/binding.cs


using System.Collections.Generic;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.ui;

base.initInstances();
instance = this;
// D.assert(() => {
// _debugAddStackFilters();
// return true;
// }());
D.assert(() => {
// _debugAddStackFilters();
return true;
});
_buildOwner = new BuildOwner();
buildOwner.onBuildScheduled = _handleBuildScheduled;

5
com.unity.uiwidgets/Runtime/widgets/container.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.widgets {
public class DecoratedBox : SingleChildRenderObjectWidget {

return padding;
}
EdgeInsets decorationPadding = decoration.padding;
Debug.LogError("EdgeInsets needs to be update to EdgeInsetsGeometry");
EdgeInsets decorationPadding = (EdgeInsets)decoration.padding;
if (padding == null) {
return decorationPadding;
}

11
com.unity.uiwidgets/Runtime/widgets/debug.cs


return true;
}
/*static int debugDoublePrecision;
public static string debugFormatDouble(float value) {
if (value == null) {
return "null";
}
if (debugDoublePrecision != null) {
return value.toStringAsPrecision(debugDoublePrecision);
}
return value.toStringAsFixed(1);
}*/
internal static UIWidgetsErrorDetails _debugReportException(
string context,
Exception exception,

3
com.unity.uiwidgets/Runtime/widgets/disposable_build_context.cs


public class DisposableBuildContext<T> where T : State{
public DisposableBuildContext(T state) {
public DisposableBuildContext(T _state) {
this._state = _state;
}
T _state;

3
com.unity.uiwidgets/Runtime/widgets/framework.cs


static Widget _defaultErrorWidgetBuilder(UIWidgetsErrorDetails details) {
string message = "";
D.assert(() => {
message = _stringify(details.exception) + "\nSee also: https://flutter.dev/docs/testing/errors";
message = _stringify(details.exception);
return true;
});
object exception = details.exception;

readonly UIWidgetsError _uiWidgetsError;
public override RenderObject createRenderObject(BuildContext context) {
//return null;
return new RenderErrorBox(message);
}

183
com.unity.uiwidgets/Runtime/widgets/image.cs


return new ImageConfiguration(
bundle: DefaultAssetBundle.of(context),
devicePixelRatio: MediaQuery.of(context, nullOk: true)?.devicePixelRatio ?? 1.0f,
//locale: Localizations.localeOf(context, nullOk: true),
locale: Localizations.localeOf(context, nullOk: true),
size: size,
platform: Application.platform
);

ImageStream stream = provider.resolve(config);
void listener(ImageInfo image, bool sync) {
if (!completer.isCompleted) {
stream.removeListener(listener);
}
SchedulerBinding.instance.addPostFrameCallback(timeStamp => { stream.removeListener(listener); });
// TODO: update
// if (!completer.isCompleted) {
// stream.removeListener(listener);
// }
//
// SchedulerBinding.instance.addPostFrameCallback(timeStamp => { stream.removeListener(listener); });
}
void errorListener(Exception exception) {

stream.removeListener(listener);
// TODO: update
// stream.removeListener(listener);
if (onError != null) {
onError(exception);
}

}
}
stream.addListener(listener: listener, onError: errorListener);
// TODO: update
// stream.addListener(listener, onError: errorListener);
public delegate Widget ImageFrameBuilder (
BuildContext context,
Widget child,
int frame,
bool wasSynchronouslyLoaded
public delegate Widget ImageFrameBuilder(
BuildContext context,
Widget child,
int frame,
bool wasSynchronouslyLoaded
// [!!!] class ImageChunkEvent is missing
BuildContext context,
Widget child//,
//ImageChunkEvent loadingProgress
BuildContext context,
Widget child,
ImageChunkEvent loadingProgress
public class Image : StatefulWidget {
public Image(
Key key = null,

bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low,
IDictionary<string, string> headers = null,
int cacheWidth = default,
int cacheHeight = default
int? cacheWidth = null,
int? cacheHeight = null
var networkImage = new NetworkImage(src, scale, headers);//image = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, NetworkImage(src, scale: scale, headers: headers));
var image = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight,
new NetworkImage(src, scale: scale, headers: headers));
image: networkImage,
image: image,
frameBuilder: frameBuilder,
loadingBuilder: loadingBuilder,
errorBuilder: errorBuilder,

Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low,
int cacheWidth = default,
int cacheHeight = default
int? cacheWidth = null,
int? cacheHeight = null
var fileImage = new FileImage(file, scale);//ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, FileImage(file, scale: scale));
var fileImage = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, new FileImage(file, scale: scale));
return new Image(
key: key,
image: fileImage,

Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low,
int cacheWidth = default,
int cacheHeight = default
int? cacheWidth = default,
int? cacheHeight = null
) {
/*image = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, scale != null
? ExactAssetImage(name, bundle: bundle, scale: scale, package: package)

Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low,
int cacheWidth = default,
int cacheHeight = default
int? cacheWidth = default,
int? cacheHeight = null
) {
// ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, MemoryImage(bytes, scale: scale));
var memoryImage = new MemoryImage(bytes, scale);

properties.add(new EnumProperty<ImageRepeat>("repeat", repeat, defaultValue: ImageRepeat.noRepeat));
properties.add(new DiagnosticsProperty<Rect>("centerSlice", centerSlice,
defaultValue: foundation_.kNullDefaultValue));
properties.add(new EnumProperty<FilterQuality>("filterQuality", filterQuality, foundation_.kNullDefaultValue));
properties.add(new EnumProperty<FilterQuality>("filterQuality", filterQuality,
foundation_.kNullDefaultValue));
public class _ImageState : State<Image> ,WidgetsBindingObserver{
public class _ImageState : State<Image>, WidgetsBindingObserver {
//ImageChunkEvent _loadingProgress;
ImageChunkEvent _loadingProgress;
bool _isListeningToStream = false;
bool _invertColors;
int _frameNumber;

StackTrace _lastStack;
public override void initState() {
base.initState();
WidgetsBinding.instance.addObserver(this);

_scrollAwareContext.dispose();
base.dispose();
}
public override void didChangeDependencies() {
_updateInvertColors();
_resolveImage();

Image image = (Image) oldWidget;
if (_isListeningToStream &&
(widget.loadingBuilder == null) != (image.loadingBuilder == null)) {
/*_imageStream.removeListener(_getListener(image.loadingBuilder));
_imageStream.addListener(_getListener());*/
_imageStream.removeListener(_getListener(image.loadingBuilder));
_imageStream.addListener(_getListener());
/*public override void didChangeAccessibilityFeatures() {
base.didChangeAccessibilityFeatures();
setState(() => {

void _updateInvertColors() {
_invertColors = MediaQuery.of(context, nullOk: true)?.invertColors
?? false;

D.assert(newStream != null);
_updateSourceStream(newStream);
}
/*ImageStreamListener _getListener(ImageLoadingBuilder loadingBuilder = null) {
loadingBuilder ??= widget.loadingBuilder;
void _onError(Exception error) {
setState(() => {
_lastException = error;
// _lastStack = stackTrace;
});
}
ImageStreamListener _getListener(ImageLoadingBuilder loadingBuilder = null) {
loadingBuilder = loadingBuilder ?? widget.loadingBuilder;
ImageChunkListener onChunk = null;
if (loadingBuilder == null) {
onChunk = _handleImageChunk;
}
ImageErrorListener onError = null;
if (widget.errorBuilder != null) {
onError = (Exception error) => {
setState(() => {
_lastException = error;
// _lastStack = stackTrace;
});
};
}
onChunk: loadingBuilder == null ? null : _handleImageChunk,
onError: widget.errorBuilder != null
? (dynamic error, StackTrace stackTrace) => {
setState(() => {
_lastException = error;
_lastStack = stackTrace;
});
}
: null
);
}*/
onChunk: onChunk,
onError: onError
);
}
/*void _handleImageFrame(ImageInfo imageInfo, bool synchronousCall) {
setState(() =>{
void _handleImageFrame(ImageInfo imageInfo, bool synchronousCall) {
setState(() => {
_imageInfo = imageInfo;
_loadingProgress = null;
_frameNumber = _frameNumber == null ? 0 : _frameNumber + 1;

void _handleImageChunk(ImageChunkEvent _event) {
D.assert(widget.loadingBuilder != null);
setState(() => {
_loadingProgress = _event;
});
}*/
setState(() => { _loadingProgress = _event; });
}
void _updateSourceStream(ImageStream newStream) {
if (_imageStream?.key == newStream?.key) {
return;

//_imageStream.removeListener(_getListener());
_imageStream.removeListener(_handleImageChanged);
_imageStream.removeListener(_getListener());
}
if (!widget.gaplessPlayback) {

/*setState(() => {
_loadingProgress = null;
_frameNumber = null;
_wasSynchronouslyLoaded = false;
});*/
//_imageStream.addListener(_getListener());
_imageStream.addListener(_handleImageChanged);
_imageStream.addListener(_getListener());
}
}

}
//_imageStream.addListener(_getListener());
_imageStream.addListener(_handleImageChanged);
_imageStream.addListener(_getListener());
_isListeningToStream = true;
}

}
//_imageStream.removeListener(_getListener());
_imageStream.removeListener(_handleImageChanged);
_imageStream.removeListener(_getListener());
if (_lastException != null) {
if (_lastException != null) {
RawImage image = new RawImage(
Widget image = new RawImage(
image: _imageInfo?.image,
width: widget.width,
height: widget.height,

invertColors: _invertColors,
filterQuality: widget.filterQuality
);
/*if (widget.frameBuilder != null)
if (widget.frameBuilder != null)
image = widget.loadingBuilder(context, image, _loadingProgress);*/
image = widget.loadingBuilder(context, image, _loadingProgress);
return image;
}

description.add(new DiagnosticsProperty<bool>("wasSynchronouslyLoaded", _wasSynchronouslyLoaded));
}
public void didChangeMetrics() {
setState();
}

2
com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs


public override Widget build(BuildContext context) {
return new Padding(
padding: _padding
padding: (EdgeInsets) _padding
.evaluate(animation)
.clamp(EdgeInsets.zero, EdgeInsets.infinity),
child: widget.child

4
com.unity.uiwidgets/Runtime/widgets/navigator.cs


widget.pages.isEmpty() || widget.onPopPage != null, () =>
"The Navigator.onPopPage must be provided to use the Navigator.pages API"
);
if (((Navigator)oldWidget).observers != widget.observers) {
if (!((Navigator)oldWidget).observers.equalsList(widget.observers)) {
foreach (NavigatorObserver observer in ((Navigator)oldWidget).observers)
observer._navigator = null;
foreach (NavigatorObserver observer in widget.observers) {

}
if (((Navigator)oldWidget).pages != widget.pages) {
if (!((Navigator)oldWidget).pages.equalsList(widget.pages)) {
D.assert(
widget.pages.isNotEmpty(), () =>
"To use the Navigator.pages, there must be at least one page in the list."

3
com.unity.uiwidgets/Runtime/widgets/pages.cs


bool fullscreenDialog = false
) : base(settings,fullscreenDialog) {
D.assert(pageBuilder != null);
D.assert(transitionsBuilder != null);
this.opaque = opaque;
this.pageBuilder = pageBuilder;
this.transitionsBuilder = transitionsBuilder ?? PagesUtils._defaultTransitionsBuilder;

3
engine/.gitignore


artifacts
build
obj
*.gen.*
*.gen.*
third_party/skia

2
engine/Build.bee.cs


"src/shell/platform/unity/unity_surface_manager.h",
"src/shell/platform/unity/win32_task_runner.cc",
"src/shell/platform/unity/win32_task_runner.h",
"src/shell/platform/unity/unity_console.cc",
"src/shell/platform/unity/unity_console.h",
"src/shell/version/version.cc",
"src/shell/version/version.h",

7
engine/README.md


Add ${PWD}/depot_tools to PATH
2. Clone the skia Repo
```
```
3. Install LLVM

Update out/Debug/args.gn with the following content:
```
clang_win = "C:\Program Files\LLVM"

## How to Build Engine
```
bee
```
```

24
engine/src/shell/platform/unity/uiwidgets_panel.cc


}
}
void UIWidgetsPanel::TakeScreenShot() {
if (process_events_) {
auto* engine = reinterpret_cast<EmbedderEngine*>(engine_);
Rasterizer::Screenshot screenshot = engine->GetShell().Screenshot(
Rasterizer::ScreenshotType::SkiaPicture, true);
const char* screenshot_char =
static_cast<const char*>(screenshot.data->data());
int size = screenshot.data->size();
SkBase64 temp;
temp.decode(screenshot_char, screenshot.data->size());
char* decoded = temp.getData();
std::ofstream myfile;
myfile.open("example.txt");
myfile.write(decoded, temp.getDataSize());
myfile.close();
}
}
UIWIDGETS_API(UIWidgetsPanel*)
UIWidgetsPanel_constructor(
Mono_Handle handle,

UIWIDGETS_API(void)
UIWidgetsPanel_onMouseLeave(UIWidgetsPanel* panel) { panel->OnMouseLeave(); }
UIWIDGETS_API(void)
UIWidgetsPanel_takeScreenShot(UIWidgetsPanel* panel) {
panel->TakeScreenShot();
}
} // namespace uiwidgets

4
engine/src/shell/platform/unity/uiwidgets_panel.h


~UIWidgetsPanel();
void OnEnable(void* native_texture_ptr, size_t width, size_t height,
float device_pixel_ratio, const char* streaming_assets_path, const char* settings);
float device_pixel_ratio, const char* streaming_assets_path,
const char* settings);
void MonoEntrypoint();

void OnMouseLeave();
void TakeScreenShot();
private:
UIWidgetsPanel(Mono_Handle handle, EntrypointCallback entrypoint_callback);

36
Samples/UIWidgetsSamples_2019_4/Assets/Scene/TextTest.unity


m_Component:
- component: {fileID: 847097469}
- component: {fileID: 847097471}
- component: {fileID: 847097472}
- component: {fileID: 847097470}
m_Layer: 5
m_Name: RawImage
m_TagString: Untagged

m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &847097471
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 847097468}
m_CullTransparentMesh: 0
--- !u!114 &847097472
--- !u!114 &847097470
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 169ec79ce040653478e1a7725f34bbe1, type: 3}
m_Script: {fileID: 11500000, guid: b7e1083a82b756840b36958a76a3e6f3, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}

width: 1
height: 1
fonts:
- family: racher
fonts:
- asset: Ranchers-Regular.ttf
weight: 0
- family: roboto
fonts:
- asset: Roboto-Italic.ttf
weight: 0
- asset: Roboto-BlackItalic.ttf
weight: 900
- family: robotox
fonts:
- asset: Roboto-Italic.ttf
weight: 0
--- !u!222 &847097471
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 847097468}
m_CullTransparentMesh: 0
--- !u!1 &1548023132
GameObject:
m_ObjectHideFlags: 0

8
Samples/UIWidgetsSamples_2019_4/Assets/Scene.meta


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

8
Samples/UIWidgetsSamples_2019_4/Assets/Script.meta


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

22
com.unity.uiwidgets/Runtime/engine2/native_console.cs


using UnityEngine;
using AOT;
using System;
using System.Runtime.InteropServices;
using NativeBindings = Unity.UIWidgets.ui.NativeBindings;
public static class NativeConsole {
internal delegate void LogDelegate(IntPtr message, int iSize);
[DllImport(NativeBindings.dllName)]
internal static extern void InitNativeConsoleDelegate(LogDelegate log);
[MonoPInvokeCallback(typeof(LogDelegate))]
internal static void LogMessageFromCpp(IntPtr message, int iSize) {
Debug.Log(Marshal.PtrToStringAnsi(message, iSize));
}
public static void OnEnable()
{
InitNativeConsoleDelegate(LogMessageFromCpp);
}
}

13
com.unity.uiwidgets/Runtime/painting/image_decoder.cs


using Unity.UIWidgets.async2;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting {
public partial class painting_ {
public static Future<ui.Image> decodeImageFromList(byte[] bytes) {
Future<Codec> codec = PaintingBinding.instance.instantiateImageCodec(bytes);
Future<FrameInfo> frameInfo = codec.then_<FrameInfo>(code => code.getNextFrame());
var result = frameInfo.then_<Image>(frame => FutureOr.value(frame.image));
return result;
}
}
}

3
com.unity.uiwidgets/Runtime/painting/image_decoder.cs.meta


fileFormatVersion: 2
guid: 8e4fc5e77c5b4ce3b8cdc8644ac3f398
timeCreated: 1610527018

22
engine/src/shell/platform/unity/unity_console.cc


#include "unity_console.h"
#include <stdarg.h>
namespace uiwidgets {
void UnityConsole::WriteLine(const char* fmt, ...) {
char log_str[512] = { 0 };
va_list ap;
va_start(ap, fmt);
vsprintf(log_str, fmt, ap);
_log(log_str, strlen(log_str));
va_end(ap);
}
LogDelegate UnityConsole::_log;
UIWIDGETS_API(void)
InitNativeConsoleDelegate(LogDelegate Log) {
UnityConsole::_log = Log;
}
}

26
engine/src/shell/platform/unity/unity_console.h


#pragma once
#include "runtime/mono_api.h"
namespace uiwidgets {
typedef void (*LogDelegate)(char* message, int iSize);
class UnityConsole{
public:
static LogDelegate _log;
/**
output the log to unity editor console window
@param fmt log format
@param ... log args
@return null
example:
UnityConsole::WriteLine("output log without fmt param");
UnityConsole::WriteLine("%s: %d + %d = %d","output log with param", 1, 2, 3);
*/
static void WriteLine(const char* fmt, ...);
};
} // namespace uiwidgets

537
Samples/UIWidgetsSamples_2019_4/Assets/Scene/CountTest.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &764046566
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 764046568}
- component: {fileID: 764046567}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &764046567
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 764046566}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &764046568
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 764046566}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &847097468
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 847097469}
- component: {fileID: 847097471}
- component: {fileID: 847097470}
m_Layer: 5
m_Name: RawImage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &847097469
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 847097468}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2122288190}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &847097470
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 847097468}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 169ec79ce040653478e1a7725f34bbe1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
fonts: []
devicePixelRatioOverride: 0
hardwareAntiAliasing: 0
--- !u!222 &847097471
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 847097468}
m_CullTransparentMesh: 0
--- !u!1 &1548023132
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1548023135}
- component: {fileID: 1548023134}
- component: {fileID: 1548023133}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1548023133
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1548023132}
m_Enabled: 1
--- !u!20 &1548023134
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1548023132}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 5.6
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1548023135
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1548023132}
m_LocalRotation: {x: 0, y: 0.7071068, z: -0.7071068, w: 0}
m_LocalPosition: {x: 0, y: 1, z: 0.32}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 180, z: 0}
--- !u!1 &1900497009
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1900497012}
- component: {fileID: 1900497011}
- component: {fileID: 1900497010}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1900497010
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1900497009}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1900497011
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1900497009}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1900497012
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1900497009}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2122288186
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2122288190}
- component: {fileID: 2122288189}
- component: {fileID: 2122288188}
- component: {fileID: 2122288187}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2122288187
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2122288186}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &2122288188
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2122288186}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &2122288189
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2122288186}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &2122288190
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2122288186}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 847097469}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}

7
Samples/UIWidgetsSamples_2019_4/Assets/Scene/CountTest.unity.meta


fileFormatVersion: 2
guid: 8314c7a04efc72842be6810d12b192ae
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

537
Samples/UIWidgetsSamples_2019_4/Assets/Scene/ImageTest.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &764046566
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 764046568}
- component: {fileID: 764046567}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &764046567
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 764046566}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &764046568
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 764046566}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &847097468
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 847097469}
- component: {fileID: 847097471}
- component: {fileID: 847097470}
m_Layer: 5
m_Name: RawImage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &847097469
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 847097468}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2122288190}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &847097470
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 847097468}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f34989adbb4345fda4362c56f72ae791, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
fonts: []
devicePixelRatioOverride: 0
hardwareAntiAliasing: 0
--- !u!222 &847097471
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 847097468}
m_CullTransparentMesh: 0
--- !u!1 &1548023132
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1548023135}
- component: {fileID: 1548023134}
- component: {fileID: 1548023133}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1548023133
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1548023132}
m_Enabled: 1
--- !u!20 &1548023134
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1548023132}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 5.6
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1548023135
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1548023132}
m_LocalRotation: {x: 0, y: 0.7071068, z: -0.7071068, w: 0}
m_LocalPosition: {x: 0, y: 1, z: 0.32}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 180, z: 0}
--- !u!1 &1900497009
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1900497012}
- component: {fileID: 1900497011}
- component: {fileID: 1900497010}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1900497010
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1900497009}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1900497011
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1900497009}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1900497012
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1900497009}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2122288186
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2122288190}
- component: {fileID: 2122288189}
- component: {fileID: 2122288188}
- component: {fileID: 2122288187}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2122288187
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2122288186}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &2122288188
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2122288186}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &2122288189
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2122288186}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &2122288190
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2122288186}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 847097469}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}

7
Samples/UIWidgetsSamples_2019_4/Assets/Scene/ImageTest.unity.meta


fileFormatVersion: 2
guid: 306ce4c6ff7164648ba07e7f7157db6f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

89
Samples/UIWidgetsSamples_2019_4/Assets/Script/CountTest.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Image = Unity.UIWidgets.widgets.Image;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample
{
public class CountTest : UIWidgetsPanel
{
protected void OnEnable()
{
base.OnEnable();
}
protected override void main()
{
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new WidgetsApp(
home: new ExampleApp(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context)
)
);
}
}
class ExampleApp : StatefulWidget
{
public ExampleApp(Key key = null) : base(key)
{
}
public override State createState()
{
return new ExampleState();
}
}
class ExampleState : State<ExampleApp>
{
int counter;
public override Widget build(BuildContext context)
{
return new Container(
color: Color.fromARGB(255, 255, 0, 0),
child: new Column(
children: new List<Widget>
{
new Text("Counter: " + counter,
style: new TextStyle(fontSize: 18, fontWeight: FontWeight.w100)),
new GestureDetector(
onTap: () =>
{
setState(() =>
{
counter++;
});
},
child: new Container(
padding: EdgeInsets.symmetric(20, 20),
color: counter % 2 == 0 ? Color.fromARGB(255, 0, 255, 0) : Color.fromARGB(255, 0, 0, 255),
child: new Text("Click Me",
style: new TextStyle(fontFamily: "racher", fontWeight: FontWeight.w100))
)
)
}
)
);
}
}
}
}

98
Samples/UIWidgetsSamples_2019_4/Assets/Script/ImageTest.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Image = Unity.UIWidgets.widgets.Image;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample
{
public class ImageTest : UIWidgetsPanel
{
protected void OnEnable()
{
base.OnEnable();
}
protected override void main()
{
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new WidgetsApp(
home: new ExampleApp(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context)
)
);
}
}
class ExampleApp : StatefulWidget
{
public ExampleApp(Key key = null) : base(key)
{
}
public override State createState()
{
return new ExampleState();
}
}
class ExampleState : State<ExampleApp>
{
private float frame = 0;
public override Widget build(BuildContext context)
{
return new Container(
child: new Column(
children: new List<Widget>
{
AnimatedLottie.file("wine.json", frame: frame, curve: Curves.linear),
new Container(
width: 100,
height: 100,
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Image.file("test.gif", gaplessPlayback: true)
),
new Container(
width: 200,
height: 100,
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Image.network(
"https://unity-cn-cms-prd-1254078910.cos.ap-shanghai.myqcloud.com/assetstore-cms-media/img-7dfe215f-0075-4f9c-9b5a-be5ee88b866b",
gaplessPlayback: true)
),
new GestureDetector(
onTap: () => { setState(() => { frame += 1; }); },
child: new Container(
color: Color.black,
padding: EdgeInsets.symmetric(20, 20),
child: new Text("Click Me",
style: new TextStyle(fontWeight: FontWeight.w700))
)
)
}
)
);
}
}
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/Script/ImageTest.cs.meta


fileFormatVersion: 2
guid: f34989adbb4345fda4362c56f72ae791
timeCreated: 1607399515

163
Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
//using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Image = Unity.UIWidgets.widgets.Image;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.rendering;
//using UIWidgetsGallery.gallery;
using Unity.UIWidgets.service;
using Brightness = Unity.UIWidgets.ui.Brightness;
using UnityEngine;
using System;
using UIWidgetsGallery.gallery;
using Color = Unity.UIWidgets.ui.Color;
using Random = UnityEngine.Random;
namespace UIWidgetsSample
{
public class UIWidgetsExample : UIWidgetsPanel
{
protected void OnEnable()
{
base.OnEnable();
}
protected override void main()
{
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new CupertinoApp(
home: new HomeScreen()
);
}
}
class HomeScreen : StatelessWidget
{
public override Widget build(BuildContext context)
{
// return new CupertinoPageScaffold(
// child: new Center(
// child: new CupertinoButton(
// child: new Text(
// "THIS IS TAB #"
// ),
// onPressed: () =>
// {
// Navigator.of(context).push(
// new CupertinoPageRoute(builder: (contex3) =>
// {
// return
// new CupertinoAlertDemo();
// })
// );
// }
// )
// //new Text("hello world!", style: CupertinoTheme.of(context).textTheme.navTitleTextStyle)
// )
// //backgroundColor: Colors.brown
// );
List<BottomNavigationBarItem> items = new List<BottomNavigationBarItem>();
items.Add(new BottomNavigationBarItem(
icon: new Icon(CupertinoIcons.bell),
title: new Text("views")
));
items.Add(new BottomNavigationBarItem(
icon: new Icon(CupertinoIcons.eye_solid),
title: new Text("articles")
));
return new CupertinoTabScaffold(
tabBar: new CupertinoTabBar(
items: items
),
tabBuilder: ((contex, index) =>
{
//return new Center(child: new Text("hello"));
return new CupertinoTabView(
builder: (contex1) =>
{
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: (index == 0) ? new Text("views") : new Text("articles")
),
child: new Center(
child: new CupertinoButton(
child: new Text(
"THIS IS TAB #",
style: CupertinoTheme.of(contex1)
.textTheme
.navTitleTextStyle
//.copyWith(fontSize:32)
),
onPressed: () =>
{
Navigator.of(contex1).push(
new CupertinoPageRoute(builder: (contex3) =>
{
return
new CupertinoAlertDemo(); //DetailScreen1(index == 0 ? "views" : "articles");
})
);
}
)
)
);
}
);
})
);
}
}
public class DetailScreen1 : StatelessWidget
{
public DetailScreen1(string topic)
{
this.topic = topic;
}
public string topic;
public override Widget build(BuildContext context)
{
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
//middle: new Text("Details")
),
child: new Center(
child: new Text("hello world")
)
);
}
}
}
}

11
Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs.meta


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

7
Samples/UIWidgetsSamples_2019_4/Assets/StreamingAssets/confetti.json.meta


fileFormatVersion: 2
guid: ac26747b511ae1e42b7ee598ca4fc76d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

163
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
//using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Image = Unity.UIWidgets.widgets.Image;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.rendering;
//using UIWidgetsGallery.gallery;
using Unity.UIWidgets.service;
using Brightness = Unity.UIWidgets.ui.Brightness;
using UnityEngine;
using System;
using UIWidgetsGallery.gallery;
using Color = Unity.UIWidgets.ui.Color;
using Random = UnityEngine.Random;
namespace UIWidgetsSample
{
public class UIWidgetsExample : UIWidgetsPanel
{
protected void OnEnable()
{
base.OnEnable();
}
protected override void main()
{
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new CupertinoApp(
home: new HomeScreen()
);
}
}
class HomeScreen : StatelessWidget
{
public override Widget build(BuildContext context)
{
// return new CupertinoPageScaffold(
// child: new Center(
// child: new CupertinoButton(
// child: new Text(
// "THIS IS TAB #"
// ),
// onPressed: () =>
// {
// Navigator.of(context).push(
// new CupertinoPageRoute(builder: (contex3) =>
// {
// return
// new CupertinoAlertDemo();
// })
// );
// }
// )
// //new Text("hello world!", style: CupertinoTheme.of(context).textTheme.navTitleTextStyle)
// )
// //backgroundColor: Colors.brown
// );
List<BottomNavigationBarItem> items = new List<BottomNavigationBarItem>();
items.Add(new BottomNavigationBarItem(
icon: new Icon(CupertinoIcons.bell),
title: new Text("views")
));
items.Add(new BottomNavigationBarItem(
icon: new Icon(CupertinoIcons.eye_solid),
title: new Text("articles")
));
return new CupertinoTabScaffold(
tabBar: new CupertinoTabBar(
items: items
),
tabBuilder: ((contex, index) =>
{
//return new Center(child: new Text("hello"));
return new CupertinoTabView(
builder: (contex1) =>
{
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: (index == 0) ? new Text("views") : new Text("articles")
),
child: new Center(
child: new CupertinoButton(
child: new Text(
"THIS IS TAB #",
style: CupertinoTheme.of(contex1)
.textTheme
.navTitleTextStyle
//.copyWith(fontSize:32)
),
onPressed: () =>
{
Navigator.of(contex1).push(
new CupertinoPageRoute(builder: (contex3) =>
{
return
new CupertinoAlertDemo(); //DetailScreen1(index == 0 ? "views" : "articles");
})
);
}
)
)
);
}
);
})
);
}
}
public class DetailScreen1 : StatelessWidget
{
public DetailScreen1(string topic)
{
this.topic = topic;
}
public string topic;
public override Widget build(BuildContext context)
{
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
//middle: new Text("Details")
),
child: new Center(
child: new Text("hello world")
)
);
}
}
}
}

/Samples/UIWidgetsSamples_2019_4/Assets/TextTest.unity → /Samples/UIWidgetsSamples_2019_4/Assets/Scene/TextTest.unity

/Samples/UIWidgetsSamples_2019_4/Assets/TextTest.unity.meta → /Samples/UIWidgetsSamples_2019_4/Assets/Scene/TextTest.unity.meta

/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs.meta → /Samples/UIWidgetsSamples_2019_4/Assets/Script/CountTest.cs.meta

正在加载...
取消
保存