浏览代码

Merge branch 'kgdev' into 'master'

fix font and finalizer race condition in webgl

See merge request upm-packages/ui-widgets/com.unity.uiwidgets!11
/main
Fan Zhang 6 年前
当前提交
fa740be6
共有 224 个文件被更改,包括 2225 次插入2494 次删除
  1. 11
      Editor/EditorExample.cs
  2. 8
      README.md
  3. 12
      Runtime/RuntimeExample.cs
  4. 4
      Runtime/animation/animation.cs
  5. 31
      Runtime/animation/animation_controller.cs
  6. 29
      Runtime/animation/animations.cs
  7. 24
      Runtime/animation/curves.cs
  8. 15
      Runtime/animation/listener_helpers.mixin.gen.cs
  9. 6
      Runtime/animation/listener_helpers.mixin.njk
  10. 45
      Runtime/animation/tween.cs
  11. 23
      Runtime/async/coroutine.cs
  12. 5
      Runtime/async/microtask_queue.cs
  13. 4
      Runtime/async/priority_queue.cs
  14. 58
      Runtime/async/timer.cs
  15. 378
      Runtime/debugger/diagnostics.cs
  16. 294
      Runtime/debugger/inpsector_panel.cs
  17. 76
      Runtime/debugger/inspector_objectgroup.cs
  18. 143
      Runtime/debugger/inspector_service.cs
  19. 168
      Runtime/debugger/inspector_treeview.cs
  20. 198
      Runtime/debugger/inspector_window.cs
  21. 55
      Runtime/editor/editor_window.cs
  22. 2
      Runtime/editor/rasterizer.cs
  23. 22
      Runtime/editor/surface.cs
  24. 198
      Runtime/engine/WidgetCanvas.cs
  25. 8
      Runtime/flow/clip_rect_layer.cs
  26. 10
      Runtime/flow/clip_rrect_layer.cs
  27. 5
      Runtime/flow/compositor_context.cs
  28. 4
      Runtime/flow/container_layer.cs
  29. 9
      Runtime/flow/layer.cs
  30. 5
      Runtime/flow/layer_tree.cs
  31. 2
      Runtime/flow/matrix_decomposition.cs
  32. 7
      Runtime/flow/opacity_layer.cs
  33. 18
      Runtime/flow/picture_layer.cs
  34. 34
      Runtime/flow/raster_cache.cs
  35. 7
      Runtime/flow/transform_layer.cs
  36. 8
      Runtime/foundation/assertions.cs
  37. 8
      Runtime/foundation/basic_types.cs
  38. 2
      Runtime/foundation/binding.cs
  39. 2
      Runtime/foundation/callback.cs
  40. 8
      Runtime/foundation/change_notifier.cs
  41. 17
      Runtime/foundation/debug.cs
  42. 75
      Runtime/foundation/diagnostics.cs
  43. 30
      Runtime/foundation/key.cs
  44. 32
      Runtime/foundation/node.cs
  45. 10
      Runtime/foundation/node.mixin.gen.cs
  46. 10
      Runtime/foundation/node.mixin.njk
  47. 2
      Runtime/foundation/observer_list.cs
  48. 8
      Runtime/foundation/print.cs
  49. 20
      Runtime/gestures/arena.cs
  50. 62
      Runtime/gestures/binding.cs
  51. 10
      Runtime/gestures/constants.cs
  52. 18
      Runtime/gestures/converter.cs
  53. 2
      Runtime/gestures/drag.cs
  54. 2
      Runtime/gestures/drag_details.cs
  55. 15
      Runtime/gestures/events.cs
  56. 8
      Runtime/gestures/hit_test.cs
  57. 2
      Runtime/gestures/long_press.cs
  58. 47
      Runtime/gestures/lsq_resolver.cs
  59. 10
      Runtime/gestures/monodrag.cs
  60. 4
      Runtime/gestures/multitap.cs
  61. 5
      Runtime/gestures/pointer_router.cs
  62. 5
      Runtime/gestures/recognizer.cs
  63. 12
      Runtime/gestures/tap.cs
  64. 2
      Runtime/gestures/team.cs
  65. 46
      Runtime/gestures/velocity_tracker.cs
  66. 44
      Runtime/painting/alignment.cs
  67. 2
      Runtime/painting/basic_types.cs
  68. 4
      Runtime/painting/binding.cs
  69. 60
      Runtime/painting/border_radius.cs
  70. 26
      Runtime/painting/borders.cs
  71. 46
      Runtime/painting/box_border.cs
  72. 52
      Runtime/painting/box_decoration.cs
  73. 23
      Runtime/painting/box_fit.cs
  74. 30
      Runtime/painting/box_shadow.cs
  75. 2
      Runtime/painting/clip.cs
  76. 2
      Runtime/painting/decoration.cs
  77. 7
      Runtime/painting/decoration_image.cs
  78. 48
      Runtime/painting/edge_insets.cs
  79. 2
      Runtime/painting/gradient.cs
  80. 16
      Runtime/painting/image_cache.cs
  81. 142
      Runtime/painting/image_provider.cs
  82. 34
      Runtime/painting/image_resolution.cs
  83. 58
      Runtime/painting/image_stream.cs
  84. 12
      Runtime/painting/matrix_utils.cs
  85. 537
      Runtime/painting/text_painter.cs
  86. 237
      Runtime/painting/text_span.cs
  87. 298
      Runtime/painting/text_style.cs
  88. 2
      Runtime/physics/clamped_simulation.cs
  89. 4
      Runtime/physics/friction_simulation.cs
  90. 2
      Runtime/physics/gravity_simulation.cs
  91. 2
      Runtime/physics/simulation.cs
  92. 13
      Runtime/physics/spring_simulation.cs
  93. 5
      Runtime/physics/tolerance.cs
  94. 2
      Runtime/physics/utils.cs
  95. 2
      Runtime/promise/EnumerableExt.cs
  96. 526
      Runtime/promise/Promise.cs
  97. 20
      Runtime/promise/PromiseException.cs
  98. 2
      Runtime/promise/PromiseHelpers.cs
  99. 5
      Runtime/promise/PromiseStateException.cs
  100. 52
      Runtime/promise/PromiseTimer.cs

11
Editor/EditorExample.cs


//
// -----------------------------------------------------------------------------
namespace Unity.UIWidgets.Editor
{
namespace Unity.UIWidgets.Editor {
/// <summary>
/// Provide a general description of the public class.
/// </summary>

/// </remarks>
public class MyPublicEditorExampleClass
{
public class MyPublicEditorExampleClass {
/// <summary>
/// Provide a description of what this private method does.
/// </summary>

/// <returns> Description of what the function returns </returns>
public int CountThingsAndDoStuff(int parameter1, int parameter2, bool parameter3)
{
public int CountThingsAndDoStuff(int parameter1, int parameter2, bool parameter3) {
}
}

8
README.md


cd <YourProjectPath>/Packages
git clone https://gitlab.cds.internal.unity3d.com/upm-packages/ui-widgets/com.unity.uiwidgets.git com.unity.uiwidgets
```
## IDE
1. Use JetBrains Rider
2. Open File -> Settings Repository....
Specify Upstream URL as "https://gitlab.cds.internal.unity3d.com/upm-packages/ui-widgets/idea-settings"
and click "Overwrite Local" or "Merge".
REF: https://www.jetbrains.com/help/idea/sharing-your-ide-settings.html#settings-repository

12
Runtime/RuntimeExample.cs


//
// -----------------------------------------------------------------------------
namespace Unity.UIWidgets
{
namespace Unity.UIWidgets {
/// <summary>
/// Provide a general description of the public class.
/// </summary>

/// </remarks>
public class MyPublicRuntimeExampleClass
{
public class MyPublicRuntimeExampleClass {
/// <summary>
/// Provide a description of what this private method does.
/// </summary>

/// <returns> Description of what the function returns </returns>
public int CountThingsAndDoStuff(int parameter1, int parameter2, bool parameter3)
{
public int CountThingsAndDoStuff(int parameter1, int parameter2, bool parameter3) {
}
}

4
Runtime/animation/animation.cs


}
public override string ToString() {
return string.Format("{0}({1})", Diagnostics.describeIdentity(this), this.toStringDetails());
return $"{Diagnostics.describeIdentity(this)}({this.toStringDetails()})";
}
public virtual string toStringDetails() {

return icon;
}
}
}
}

31
Runtime/animation/animation_controller.cs


this._internalSetValue(value ?? lowerBound);
}
private AnimationController(
AnimationController(
double value = 0.0,
TimeSpan? duration = null,
string debugLabel = null,

public void resync(TickerProvider vsync) {
Ticker oldTicker = this._ticker;
this._ticker = vsync.createTicker(_tick);
this._ticker = vsync.createTicker(this._tick);
this._ticker.absorbTicker(oldTicker);
}

double target = velocity < 0.0
? this.lowerBound - _kFlingTolerance.distance
: this.upperBound + _kFlingTolerance.distance;
Simulation simulation = new SpringSimulation(_kFlingSpringDescription, this.value, target, velocity);
Simulation simulation = new SpringSimulation(_kFlingSpringDescription, this.value,
target, velocity);
simulation.tolerance = _kFlingTolerance;
return this.animateWith(simulation);
}

string paused = this.isAnimating ? "" : "; paused";
string ticker = this._ticker == null ? "; DISPOSED" : (this._ticker.muted ? "; silenced" : "");
string label = this.debugLabel == null ? "" : "; for " + this.debugLabel;
string more = string.Format("{0} {1:F3}", base.toStringDetails(), this.value);
string more = $"{base.toStringDetails()} {this.value:F3}";
return more + paused + ticker + label;
}

class _InterpolationSimulation : Simulation {
internal _InterpolationSimulation(double _begin, double _end, TimeSpan duration, Curve _curve) {
this._begin = _begin;
this._end = _end;
this._curve = _curve;
internal _InterpolationSimulation(double begin, double end, TimeSpan duration, Curve curve) {
this._begin = begin;
this._end = end;
this._curve = curve;
D.assert(duration.Ticks > 0);
this._durationInSeconds = (double) duration.Ticks / TimeSpan.TicksPerSecond;

class _RepeatingSimulation : Simulation {
internal _RepeatingSimulation(double min, double max, TimeSpan period) {
this.min = min;
this.max = max;
this._min = min;
this._max = max;
readonly double min;
readonly double max;
readonly double _min;
readonly double _max;
return MathUtils.lerpDouble(this.min, this.max, t);
return MathUtils.lerpDouble(this._min, this._max, t);
return (this.max - this.min) / this._periodInSeconds;
return (this._max - this._min) / this._periodInSeconds;
}
public override bool isDone(double timeInSeconds) {

}
}

29
Runtime/animation/animations.cs


}
public override string toStringDetails() {
return string.Format("{0} {1}; paused", base.toStringDetails(), this.value);
return $"{base.toStringDetails()} {this.value}; paused";
}
}

public override string ToString() {
if (this.parent == null) {
return string.Format("{0}(null; {1} {2:F3}", this.GetType(), this.toStringDetails(), this.value);
return $"{this.GetType()}(null; {this.toStringDetails()} {this.value:F3}";
return string.Format("{0}\u27A9{1}", this.parent, this.GetType());
return $"{this.parent}\u27A9{this.GetType()}";
}
}

public class TrainHoppingAnimation :
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<double> {
public TrainHoppingAnimation(
Animation<double> _currentTrain = null,
Animation<double> _nextTrain = null,
Animation<double> currentTrain = null,
Animation<double> nextTrain = null,
D.assert(_currentTrain != null);
this._currentTrain = _currentTrain;
this._nextTrain = _nextTrain;
D.assert(currentTrain != null);
this._currentTrain = currentTrain;
this._nextTrain = nextTrain;
this.onSwitchedTrain = onSwitchedTrain;
if (this._nextTrain != null) {

public override string ToString() {
if (this._nextTrain != null) {
return string.Format("{0}\u27A9{1}(next: {2})", this.currentTrain, this.GetType(), this._nextTrain);
return $"{this.currentTrain}\u27A9{this.GetType()}(next: {this._nextTrain})";
return string.Format("{0}\u27A9{1}(no next)", this.currentTrain, this.GetType());
return $"{this.currentTrain}\u27A9{this.GetType()}(no next)";
}
}

public override AnimationStatus status {
get {
if (this.next.status == AnimationStatus.forward || this.next.status == AnimationStatus.reverse)
if (this.next.status == AnimationStatus.forward || this.next.status == AnimationStatus.reverse) {
}
return string.Format("{0}({1}, {2})", this.GetType(), this.first, this.next);
return $"{this.GetType()}({this.first}, {this.next})";
}
AnimationStatus _lastStatus;

T _lastValue;
void _maybeNotifyListeners() {
if (object.Equals(this.value, this._lastValue)) {
if (Equals(this.value, this._lastValue)) {
this._lastValue = this.value;
this.notifyListeners();
}

public static readonly Animation<double> kAlwaysDismissedAnimation = new _AlwaysDismissedAnimation();
}
}
}

24
Runtime/animation/curves.cs


}
public override string ToString() {
return string.Format("{0}({1})", this.GetType(), this.count);
return $"{this.GetType()}({this.count})";
}
}

public override string ToString() {
if (!(this.curve is _Linear)) {
return string.Format("{0}({1}\u22EF{2}\u27A9{3}", this.GetType(), this.begin, this.end, this.curve);
return $"{this.GetType()}({this.begin}\u22EF{this.end}\u27A9{this.curve}";
return string.Format("{0}({1}\u22EF{2})", this.GetType(), this.begin, this.end);
return $"{this.GetType()}({this.begin}\u22EF{this.end})";
}
}

}
public override string ToString() {
return string.Format("{0}({1:F2}, {2:F2}, {3:F2}, {4:F2})", this.GetType(), this.a, this.b, this.c, this.d);
return $"{this.GetType()}({this.a:F2}, {this.b:F2}, {this.c:F2}, {this.d:F2})";
}
}

}
public override string ToString() {
return string.Format("{0}({1})", this.GetType(), this.curve);
return $"{this.GetType()}({this.curve})";
}
}

return -Math.Pow(2.0, 10.0 * t) * Math.Sin((t - s) * (Math.PI * 2.0) / this.period);
}
public override String ToString() {
return string.Format("{0}({1})", this.GetType(), this.period);
public override string ToString() {
return $"{this.GetType()}({this.period})";
}
}

return Math.Pow(2.0, -10.0 * t) * Math.Sin((t - s) * (Math.PI * 2.0) / this.period) + 1.0;
}
public override String ToString() {
return string.Format("{0}({1})", this.GetType(), this.period);
public override string ToString() {
return $"{this.GetType()}({this.period})";
}
}

}
}
public override String ToString() {
return string.Format("{0}({1})", this.GetType(), this.period);
public override string ToString() {
return $"{this.GetType()}({this.period})";
}
}

return 7.5625 * t * t + 0.984375;
}
}
}
}

15
Runtime/animation/listener_helpers.mixin.gen.cs


if (this._listeners.Contains(listener)) {
listener();
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

if (this._listeners.Contains(listener)) {
listener();
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

if (this._statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

if (this._statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

if (this._statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

6
Runtime/animation/listener_helpers.mixin.njk


if (this._listeners.Contains(listener)) {
listener();
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

if (this._statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

45
Runtime/animation/tween.cs


}
class _AnimatedEvaluation<T> : AnimationWithParentMixin<double, T> {
internal _AnimatedEvaluation(Animation<double> _parent, Animatable<T> _evaluatable) {
internal _AnimatedEvaluation(Animation<double> parent, Animatable<T> evaluatable) {
this._evaluatable = _evaluatable;
this._evaluatable = evaluatable;
}
public override Animation<double> parent {

}
public override string ToString() {
return string.Format("{0}\u27A9{1}\u27A9{2}", this.parent, this._evaluatable, this.value);
return $"{this.parent}\u27A9{this._evaluatable}\u27A9{this.value}";
}
public override string toStringDetails() {

class _ChainedEvaluation<T> : Animatable<T> {
internal _ChainedEvaluation(Animatable<double> _parent, Animatable<T> _evaluatable) {
this._parent = _parent;
this._evaluatable = _evaluatable;
internal _ChainedEvaluation(Animatable<double> parent, Animatable<T> evaluatable) {
this._parent = parent;
this._evaluatable = evaluatable;
}
readonly Animatable<double> _parent;

}
public override string ToString() {
return string.Format("{0}\u27A9{1}", this._parent, this._evaluatable);
return $"{this._parent}\u27A9{this._evaluatable}";
}
}

}
public override string ToString() {
return string.Format("{0}({1} \u2192 {2})", this.GetType(), this.begin, this.end);
return $"{this.GetType()}({this.begin} \u2192 {this.end})";
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((Tween<T>) obj);
}

}
public static bool operator ==(Tween<T> left, Tween<T> right) {
return object.Equals(left, right);
return Equals(left, right);
return !object.Equals(left, right);
return !Equals(left, right);
this.parent = parent;
}
public readonly Tween<T> parent;

}
public override string ToString() {
return string.Format("{0}(curve: {1})", this.GetType(), this.curve);
return $"{this.GetType()}(curve: {this.curve})";
}
}

23
Runtime/async/coroutine.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using RSG;
using Unity.UIWidgets.foundation;

namespace Unity.UIWidgets.async {
public class UIWidgetsCoroutine {
_WaitforSecondsProcessor _waitProcessor;
_WaitForSecondsProcessor _waitProcessor;
_WaitForCoroutineProcessor _waitForCoroutine;
_WaitForAsyncOPProcessor _waitForAsyncOPProcessor;

internal bool isDone;
readonly Promise<object> _promise = new Promise<object>();
public IPromise<object> promise => this._promise;
public IPromise<object> promise {
get { return this._promise; }
}
internal UIWidgetsCoroutine(IEnumerator routine, Window window, bool isBackground = false) {
D.assert(routine != null);

bool hasNext;
try {
hasNext = this._processIEnumeratorRecursive(this._routine);
}
catch (Exception ex) {
} catch (Exception ex) {
this.stop(ex);
return;
}

}
}
struct _WaitforSecondsProcessor {
struct _WaitForSecondsProcessor {
UIWidgetsWaitForSeconds _current;
double _targetTime;

}
}
internal class BackgroundCallbacks : IDisposable {
class BackgroundCallbacks : IDisposable {
return null;
return null;
return _instance;
}

try {
callbackNode.callback();
}
catch (Exception ex) {
} catch (Exception ex) {
Debug.LogError("Failed to execute callback in BackgroundCallbacks: " + ex);
}

public volatile bool isDone;
}
}
}
}

5
Runtime/async/microtask_queue.cs


var action = this._queue.Dequeue();
try {
action();
}
catch (Exception ex) {
} catch (Exception ex) {
}
}

4
Runtime/async/priority_queue.cs


namespace Unity.UIWidgets.async {
public class PriorityQueue<T> where T : IComparable<T> {
private readonly List<T> _data;
readonly List<T> _data;
public PriorityQueue() {
this._data = new List<T>();

return true; // passed all checks
}
}
}
}

58
Runtime/async/timer.cs


namespace Unity.UIWidgets.async {
public abstract class Timer : IDisposable {
public abstract void cancel();
public static double timeSinceStartup {
get {
#if UNITY_EDITOR

}
}
public static TimeSpan timespanSinceStartup => TimeSpan.FromSeconds(timeSinceStartup);
public static TimeSpan timespanSinceStartup {
get { return TimeSpan.FromSeconds(timeSinceStartup); }
}
static readonly object _syncObj = new object();
static LinkedList<Action> _callbacks = new LinkedList<Action>();
static readonly List<Action> _callbacks = new List<Action>();
internal static void runInMainFromFinalizer(Action callback) {
lock (_syncObj) {
_callbacks.AddLast(callback);
}
}
lock (_callbacks) {
_callbacks.Add(callback);
lock (_syncObj) {
_callbacks.AddLast(callback);
Action[] callbacks;
LinkedList<Action> callbacks;
lock (_callbacks) {
callbacks = _callbacks.ToArray();
_callbacks.Clear();
lock (_syncObj) {
callbacks = _callbacks;
_callbacks = new LinkedList<Action>();
}
catch (Exception ex) {
} catch (Exception ex) {
Debug.LogError("Error to execute runInMain callback: " + ex);
}
}

}
}
private class TimerImpl : Timer, IComparable<TimerImpl> {
class TimerImpl : Timer, IComparable<TimerImpl> {
private double _deadline;
private readonly Action _callback;
private bool _done;
double _deadline;
readonly Action _callback;
bool _done;
this._deadline = Timer.timeSinceStartup + duration.TotalSeconds;
this._deadline = timeSinceStartup + duration.TotalSeconds;
this._callback = callback;
this.periodic = periodic;
this._done = false;

}
public double deadline => this._deadline;
public double deadline {
get { return this._deadline; }
}
public bool done => this._done;
public bool done {
get { return this._done; }
}
public void invoke() {
if (this._done) {

var now = Timer.timeSinceStartup;
var now = timeSinceStartup;
if (!this.periodic) {
this._done = true;
}

}
catch (Exception ex) {
} catch (Exception ex) {
Debug.LogError("Error to execute timer callback: " + ex);
}

}
}
}
}
}

378
Runtime/debugger/diagnostics.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.debugger
{
public class DiagnosticsNode : IEquatable<DiagnosticsNode>
{
private readonly Dictionary<string, object> _json; // todo use json class such as simple json
namespace Unity.UIWidgets.debugger {
public class DiagnosticsNode : IEquatable<DiagnosticsNode> {
readonly Dictionary<string, object> _json; // todo use json class such as simple json
private DiagnosticsNode _parent;
DiagnosticsNode _parent;
public DiagnosticsNode(Dictionary<string, object> json, bool isProperty)
{
public DiagnosticsNode(Dictionary<string, object> json, bool isProperty) {
public bool Equals(DiagnosticsNode other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Equals(diagnosticRef, other.diagnosticRef);
public bool Equals(DiagnosticsNode other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.diagnosticRef, other.diagnosticRef);
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((DiagnosticsNode) obj);
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((DiagnosticsNode) obj);
public static bool operator ==(DiagnosticsNode left, DiagnosticsNode right)
{
public static bool operator ==(DiagnosticsNode left, DiagnosticsNode right) {
public static bool operator !=(DiagnosticsNode left, DiagnosticsNode right)
{
public static bool operator !=(DiagnosticsNode left, DiagnosticsNode right) {
public DiagnosticsNode parent
{
get { return _parent; }
set { _parent = value; }
public DiagnosticsNode parent {
get { return this._parent; }
set { this._parent = value; }
public string getStringMember(string memberName)
{
public string getStringMember(string memberName) {
_json.TryGetValue(memberName, out ret);
this._json.TryGetValue(memberName, out ret);
public string separator
{
get { return showSeparator ? ":" : ""; }
public string separator {
get { return this.showSeparator ? ":" : ""; }
public string name
{
get { return getStringMember("name"); }
public string name {
get { return this.getStringMember("name"); }
public bool showSeparator
{
get { return getBoolMember("showSeparator", true); }
public bool showSeparator {
get { return this.getBoolMember("showSeparator", true); }
public string description
{
get { return getStringMember("description"); }
public string description {
get { return this.getStringMember("description"); }
public DiagnosticLevel level
{
get { return getLevelMember("level", DiagnosticLevel.info); }
public DiagnosticLevel level {
get { return this.getLevelMember("level", DiagnosticLevel.info); }
public bool showName
{
get { return getBoolMember("showName", true); }
public bool showName {
get { return this.getBoolMember("showName", true); }
public string emptyBodyDescription
{
get { return getStringMember("emptyBodyDescription"); }
public string emptyBodyDescription {
get { return this.getStringMember("emptyBodyDescription"); }
public DiagnosticsTreeStyle style
{
get { return getStyleMember("style", DiagnosticsTreeStyle.sparse); }
public DiagnosticsTreeStyle style {
get { return this.getStyleMember("style", DiagnosticsTreeStyle.sparse); }
public string type
{
get { return getStringMember("type"); }
public string type {
get { return this.getStringMember("type"); }
public bool isQuoted
{
get { return getBoolMember("quoted", false); }
public bool isQuoted {
get { return this.getBoolMember("quoted", false); }
public bool hasIsQuoted
{
get { return _json.ContainsKey("quoted"); }
public bool hasIsQuoted {
get { return this._json.ContainsKey("quoted"); }
public string unit
{
get { return getStringMember("unit"); }
public string unit {
get { return this.getStringMember("unit"); }
public bool hasUnit
{
get { return _json.ContainsKey("unit"); }
public bool hasUnit {
get { return this._json.ContainsKey("unit"); }
public string numberToString
{
get { return getStringMember("numberToString"); }
public string numberToString {
get { return this.getStringMember("numberToString"); }
public bool hasNumberToString
{
get { return _json.ContainsKey("numberToString"); }
public bool hasNumberToString {
get { return this._json.ContainsKey("numberToString"); }
public string ifTrue
{
get { return getStringMember("ifTrue"); }
public string ifTrue {
get { return this.getStringMember("ifTrue"); }
public bool hasIfTrue
{
get { return _json.ContainsKey("ifTrue"); }
public bool hasIfTrue {
get { return this._json.ContainsKey("ifTrue"); }
public string ifFalse
{
get { return getStringMember("ifFalse"); }
public string ifFalse {
get { return this.getStringMember("ifFalse"); }
public bool hasIfFalse
{
get { return _json.ContainsKey("ifFalse"); }
public bool hasIfFalse {
get { return this._json.ContainsKey("ifFalse"); }
public List<string> values
{
get
{
public List<string> values {
get {
_json.TryGetValue("values", out value);
if (value == null)
{
this._json.TryGetValue("values", out value);
if (value == null) {
return null;
}

public bool hasValues
{
get { return _json.ContainsKey("values"); }
public bool hasValues {
get { return this._json.ContainsKey("values"); }
public string ifPresent
{
get { return getStringMember("ifPresent"); }
public string ifPresent {
get { return this.getStringMember("ifPresent"); }
public bool hasIfPresent
{
get { return _json.ContainsKey("ifPresent"); }
public bool hasIfPresent {
get { return this._json.ContainsKey("ifPresent"); }
public string defaultValue
{
get { return getStringMember("defaultValue"); }
public string defaultValue {
get { return this.getStringMember("defaultValue"); }
public bool hasDefaultValue
{
get { return _json.ContainsKey("defaultValue"); }
public bool hasDefaultValue {
get { return this._json.ContainsKey("defaultValue"); }
public string ifEmpty
{
get { return getStringMember("ifEmpty"); }
public string ifEmpty {
get { return this.getStringMember("ifEmpty"); }
public string ifNull
{
get { return getStringMember("ifNull"); }
public string ifNull {
get { return this.getStringMember("ifNull"); }
public string tooltip
{
get { return getStringMember("tooltip"); }
public string tooltip {
get { return this.getStringMember("tooltip"); }
public bool hasTooltip
{
get { return _json.ContainsKey("tooltip"); }
public bool hasTooltip {
get { return this._json.ContainsKey("tooltip"); }
public bool missingIfNull
{
get { return getBoolMember("missingIfNull", false); }
public bool missingIfNull {
get { return this.getBoolMember("missingIfNull", false); }
public string exception
{
get { return getStringMember("exception"); }
public string exception {
get { return this.getStringMember("exception"); }
public bool hasException
{
get { return _json.ContainsKey("exception"); }
public bool hasException {
get { return this._json.ContainsKey("exception"); }
public string propertyType
{
get { return getStringMember("propertyType"); }
public string propertyType {
get { return this.getStringMember("propertyType"); }
public DiagnosticLevel defaultLevel
{
get { return getLevelMember("defaultLevel", DiagnosticLevel.info); }
public DiagnosticLevel defaultLevel {
get { return this.getLevelMember("defaultLevel", DiagnosticLevel.info); }
public bool isDiagnosticableValue
{
get { return getBoolMember("isDiagnosticableValue", false); }
public bool isDiagnosticableValue {
get { return this.getBoolMember("isDiagnosticableValue", false); }
public InspectorInstanceRef valueRef
{
get
{
var id = getStringMember("valueId");
public InspectorInstanceRef valueRef {
get {
var id = this.getStringMember("valueId");
public List<DiagnosticsNode> children
{
get
{
public List<DiagnosticsNode> children {
get {
_json.TryGetValue("children", out value);
if (value == null)
{
this._json.TryGetValue("children", out value);
if (value == null) {
return new List<DiagnosticsNode>();
}

}
}
public Dictionary<string, object> valuePropertiesJson
{
get
{
public Dictionary<string, object> valuePropertiesJson {
get {
_json.TryGetValue("valueProperties", out value);
this._json.TryGetValue("valueProperties", out value);
public bool isColorProperty
{
get { return isProperty && (propertyType == typeof(Color).ToString()); }
public bool isColorProperty {
get { return this.isProperty && (this.propertyType == typeof(Color).ToString()); }
//
// public bool isEnumProperty
// {

//
private bool getBoolMember(string memberName, bool defaultValue = false)
{
bool getBoolMember(string memberName, bool defaultValue = false) {
if (!_json.TryGetValue(memberName, out value))
{
if (!this._json.TryGetValue(memberName, out value)) {
if (value == null)
{
if (value == null) {
return defaultValue;
}

private DiagnosticLevel getLevelMember(string memberName, DiagnosticLevel defaultValue)
{
return getEnumMember(memberName, defaultValue);
DiagnosticLevel getLevelMember(string memberName, DiagnosticLevel defaultValue) {
return this.getEnumMember(memberName, defaultValue);
private DiagnosticsTreeStyle getStyleMember(string memberName, DiagnosticsTreeStyle defaultValue)
{
return getEnumMember(memberName, defaultValue);
DiagnosticsTreeStyle getStyleMember(string memberName, DiagnosticsTreeStyle defaultValue) {
return this.getEnumMember(memberName, defaultValue);
private T getEnumMember<T>(string memberName, T defaultValue)
{
T getEnumMember<T>(string memberName, T defaultValue) {
if (!_json.TryGetValue(memberName, out value))
{
if (!this._json.TryGetValue(memberName, out value)) {
if (value == null)
{
if (value == null) {
return defaultValue;
}

public InspectorInstanceRef diagnosticRef
{
get { return new InspectorInstanceRef(_json["objectId"].ToString()); }
public InspectorInstanceRef diagnosticRef {
get { return new InspectorInstanceRef(this._json["objectId"].ToString()); }
public List<DiagnosticsNode> inlineProperties
{
get
{
public List<DiagnosticsNode> inlineProperties {
get {
_json.TryGetValue("properties", out value);
if (value != null)
{
foreach (var v in (IEnumerable<Dictionary<string, object>>) value)
{
this._json.TryGetValue("properties", out value);
if (value != null) {
foreach (var v in (IEnumerable<Dictionary<string, object>>) value) {
properties.Add(new DiagnosticsNode(v, true));
}
}

}
public class InspectorInstanceRef : IEquatable<InspectorInstanceRef>
{
public class InspectorInstanceRef : IEquatable<InspectorInstanceRef> {
public InspectorInstanceRef(string id)
{
public InspectorInstanceRef(string id) {
public bool Equals(InspectorInstanceRef other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return string.Equals(id, other.id);
public bool Equals(InspectorInstanceRef other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return string.Equals(this.id, other.id);
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((InspectorInstanceRef) obj);
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((InspectorInstanceRef) obj);
public override int GetHashCode()
{
return (id != null ? id.GetHashCode() : 0);
public override int GetHashCode() {
return (this.id != null ? this.id.GetHashCode() : 0);
public static bool operator ==(InspectorInstanceRef left, InspectorInstanceRef right)
{
public static bool operator ==(InspectorInstanceRef left, InspectorInstanceRef right) {
public static bool operator !=(InspectorInstanceRef left, InspectorInstanceRef right)
{
public static bool operator !=(InspectorInstanceRef left, InspectorInstanceRef right) {
public override string ToString()
{
return string.Format("Id: {0}", id);
public override string ToString() {
return $"Id: {this.id}";
}
}

294
Runtime/debugger/inpsector_panel.cs


using UnityEditor.IMGUI.Controls;
using UnityEngine;
namespace Unity.UIWidgets.debugger
{
public class InspectorPanel
{
namespace Unity.UIWidgets.debugger {
public class InspectorPanel {
private const float splitterHeight = 8;
private readonly InspectorTreeView m_TreeView;
private readonly InspectorTreeView m_DetailTreeView;
private readonly InspectorService m_InspectorService;
const float splitterHeight = 8;
readonly InspectorTreeView m_TreeView;
readonly InspectorTreeView m_DetailTreeView;
readonly InspectorService m_InspectorService;
private readonly EditorWindow m_Window;
private readonly string m_GroupName;
private Vector2 m_PropertyScrollPos = new Vector2(0, 0);
private bool m_NeedSelectionUpdate = true;
private bool m_NeedDetailUpdate = true;
private List<DiagnosticsNode> m_Properties;
private InspectorInstanceRef m_SelectedNodeRef;
private bool m_VisibleToUser;
private TimeSpan m_LastPropertyRefresh = TimeSpan.Zero;
private float m_SplitOffset = -1;
readonly EditorWindow m_Window;
readonly string m_GroupName;
Vector2 m_PropertyScrollPos = new Vector2(0, 0);
bool m_NeedSelectionUpdate = true;
bool m_NeedDetailUpdate = true;
List<DiagnosticsNode> m_Properties;
InspectorInstanceRef m_SelectedNodeRef;
bool m_VisibleToUser;
TimeSpan m_LastPropertyRefresh = TimeSpan.Zero;
float m_SplitOffset = -1;
public InspectorPanel(EditorWindow window, WidgetTreeType treeType, InspectorService inspectorService,
float? splitOffset = null)
{
public InspectorPanel(EditorWindow window, WidgetTreeType treeType, InspectorService inspectorService,
float? splitOffset = null) {
this.m_InspectorService.selectionChanged += handleSelectionChanged;
m_TreeView = new InspectorTreeView(new TreeViewState());
m_TreeView.onNodeSelectionChanged += OnNodeSelectionChanged;
m_TreeView.Reload();
if (treeType == WidgetTreeType.Widget)
{
m_DetailTreeView = new InspectorTreeView(new TreeViewState());
m_DetailTreeView.Reload();
this.m_InspectorService.selectionChanged += this.handleSelectionChanged;
this.m_TreeView = new InspectorTreeView(new TreeViewState());
this.m_TreeView.onNodeSelectionChanged += this.OnNodeSelectionChanged;
this.m_TreeView.Reload();
if (treeType == WidgetTreeType.Widget) {
this.m_DetailTreeView = new InspectorTreeView(new TreeViewState());
this.m_DetailTreeView.Reload();
m_GroupName = InspectorObjectGroupManager.Instance.nextGroupName("inspector");
m_SplitOffset = splitOffset ?? window.position.height / 2;
this.m_GroupName = Singleton<InspectorObjectGroupManager>.Instance.nextGroupName("inspector");
this.m_SplitOffset = splitOffset ?? window.position.height / 2;
public string title
{
get { return treeType == WidgetTreeType.Widget ? "Widgets" : "Render Tree"; }
public string title {
get { return this.treeType == WidgetTreeType.Widget ? "Widgets" : "Render Tree"; }
public bool visibleToUser
{
get { return m_VisibleToUser; }
set
{
if (m_VisibleToUser == value)
{
public bool visibleToUser {
get { return this.m_VisibleToUser; }
set {
if (this.m_VisibleToUser == value) {
m_VisibleToUser = value;
if (value)
{
m_NeedSelectionUpdate = true;
m_NeedDetailUpdate = true;
this.m_VisibleToUser = value;
if (value) {
this.m_NeedSelectionUpdate = true;
this.m_NeedDetailUpdate = true;
public PanelState PanelState
{
get { return new PanelState(){splitOffset = m_SplitOffset, treeType = treeType}; }
public PanelState PanelState {
get { return new PanelState() {splitOffset = this.m_SplitOffset, treeType = this.treeType}; }
public void Close()
{
this.m_InspectorService.selectionChanged -= handleSelectionChanged;
if (m_InspectorService != null)
{
m_InspectorService.disposeGroup(m_GroupName);
public void Close() {
this.m_InspectorService.selectionChanged -= this.handleSelectionChanged;
if (this.m_InspectorService != null) {
this.m_InspectorService.disposeGroup(this.m_GroupName);
public void OnGUI()
{
if (Event.current.type != EventType.Layout)
{
public void OnGUI() {
if (Event.current.type != EventType.Layout) {
m_SplitOffset = Math.Max(0, m_SplitOffset);
var rect = EditorGUILayout.GetControlRect(GUILayout.ExpandWidth(true), GUILayout.Height(m_SplitOffset));
m_TreeView.OnGUI(rect);
this.m_SplitOffset = Math.Max(0, this.m_SplitOffset);
var rect = EditorGUILayout.GetControlRect(GUILayout.ExpandWidth(true),
GUILayout.Height(this.m_SplitOffset));
this.m_TreeView.OnGUI(rect);
GUILayout.Box("",
GUILayout.ExpandWidth(true),
GUILayout.Height(splitterHeight));

if (m_DetailTreeView != null)
{
if (this.m_DetailTreeView != null) {
m_DetailTreeView.OnGUI(rect2);
this.m_DetailTreeView.OnGUI(rect2);
if (m_Properties != null)
{
if (this.m_Properties != null) {
m_PropertyScrollPos = EditorGUILayout.BeginScrollView(m_PropertyScrollPos);
foreach (var property in m_Properties)
{
if (property.isColorProperty)
{
this.m_PropertyScrollPos = EditorGUILayout.BeginScrollView(this.m_PropertyScrollPos);
foreach (var property in this.m_Properties) {
if (property.isColorProperty) {
var properties = property.valuePropertiesJson;
int alpha = Util.GetIntProperty(properties, "alpha");
int red = Util.GetIntProperty(properties, "red");

var color = new UnityEngine.Color(red / 255.0f, green / 255.0f, blue / 255.0f, alpha / 255.0f);
var color = new Color(red / 255.0f, green / 255.0f, blue / 255.0f, alpha / 255.0f);
}
else
{
} else {
EditorGUILayout.TextField(property.name, property.description);
}
}

EditorGUILayout.EndVertical();
if (Event.current.type == EventType.Repaint)
{
if (splitterRect.yMax > m_Window.position.height)
{
m_SplitOffset -= splitterRect.yMax - m_Window.position.height;
m_Window.Repaint();
}
if (Event.current.type == EventType.Repaint) {
if (splitterRect.yMax > this.m_Window.position.height) {
this.m_SplitOffset -= splitterRect.yMax - this.m_Window.position.height;
this.m_Window.Repaint();
}
public void LoadTree()
{
var node = treeType == WidgetTreeType.Widget
? m_InspectorService.getRootWidgetSummaryTree(m_GroupName)
: m_InspectorService.getRootRenderObject(m_GroupName);
m_TreeView.node = node;
public void LoadTree() {
var node = this.treeType == WidgetTreeType.Widget
? this.m_InspectorService.getRootWidgetSummaryTree(this.m_GroupName)
: this.m_InspectorService.getRootRenderObject(this.m_GroupName);
this.m_TreeView.node = node;
public void Update()
{
if (!m_VisibleToUser)
{
public void Update() {
if (!this.m_VisibleToUser) {
if (m_TreeView.node == null)
{
LoadTree();
if (this.m_TreeView.node == null) {
this.LoadTree();
updateSelection();
updateDetailTree();
this.updateSelection();
this.updateDetailTree();
if (treeType == WidgetTreeType.Render &&
Timer.timespanSinceStartup - m_LastPropertyRefresh > TimeSpan.FromMilliseconds(200))
{
m_LastPropertyRefresh = Timer.timespanSinceStartup;
m_Properties = m_SelectedNodeRef == null
if (this.treeType == WidgetTreeType.Render &&
Timer.timespanSinceStartup - this.m_LastPropertyRefresh > TimeSpan.FromMilliseconds(200)) {
this.m_LastPropertyRefresh = Timer.timespanSinceStartup;
this.m_Properties = this.m_SelectedNodeRef == null
: m_InspectorService.getProperties(m_SelectedNodeRef, m_GroupName);
m_Properties = m_Properties.Where((p) => p.level != DiagnosticLevel.hidden).ToList();
: this.m_InspectorService.getProperties(this.m_SelectedNodeRef, this.m_GroupName);
this.m_Properties = this.m_Properties.Where((p) => p.level != DiagnosticLevel.hidden).ToList();
m_Window.Repaint();
this.m_Window.Repaint();
private void OnNodeSelectionChanged(DiagnosticsNode node)
{
m_SelectedNodeRef = node == null ? null : node.diagnosticRef;
m_InspectorService.setSelection(node == null ? null : node.valueRef, m_GroupName);
m_NeedDetailUpdate = m_DetailTreeView != null;
void OnNodeSelectionChanged(DiagnosticsNode node) {
this.m_SelectedNodeRef = node == null ? null : node.diagnosticRef;
this.m_InspectorService.setSelection(node == null ? null : node.valueRef, this.m_GroupName);
this.m_NeedDetailUpdate = this.m_DetailTreeView != null;
private void handleSelectionChanged()
{
m_NeedSelectionUpdate = true;
m_NeedDetailUpdate = true;
void handleSelectionChanged() {
this.m_NeedSelectionUpdate = true;
this.m_NeedDetailUpdate = true;
private void updateSelection()
{
if (!m_NeedSelectionUpdate)
{
void updateSelection() {
if (!this.m_NeedSelectionUpdate) {
m_NeedSelectionUpdate = false;
var diagnosticsNode = m_InspectorService.getSelection(m_TreeView.selectedNode, treeType, true, m_GroupName);
m_SelectedNodeRef = diagnosticsNode == null ? null : diagnosticsNode.diagnosticRef;
this.m_NeedSelectionUpdate = false;
var diagnosticsNode = this.m_InspectorService.getSelection(this.m_TreeView.selectedNode, this.treeType,
true, this.m_GroupName);
this.m_SelectedNodeRef = diagnosticsNode == null ? null : diagnosticsNode.diagnosticRef;
if (diagnosticsNode != null)
{
var item = m_TreeView.getTreeItemByValueRef(diagnosticsNode.valueRef);
if (item == null)
{
LoadTree();
item = m_TreeView.getTreeItemByValueRef(diagnosticsNode.valueRef);
if (diagnosticsNode != null) {
var item = this.m_TreeView.getTreeItemByValueRef(diagnosticsNode.valueRef);
if (item == null) {
this.LoadTree();
item = this.m_TreeView.getTreeItemByValueRef(diagnosticsNode.valueRef);
m_TreeView.CollapseAll();
if (item != null)
{
m_TreeView.SetSelection(new List<int> {item.id}, TreeViewSelectionOptions.RevealAndFrame);
this.m_TreeView.CollapseAll();
if (item != null) {
this.m_TreeView.SetSelection(new List<int> {item.id}, TreeViewSelectionOptions.RevealAndFrame);
} else {
this.m_TreeView.SetSelection(new List<int>());
else
{
m_TreeView.SetSelection(new List<int>());
}
m_TreeView.Repaint();
this.m_TreeView.Repaint();
private void updateDetailTree()
{
D.assert(!m_NeedSelectionUpdate);
if (!m_NeedDetailUpdate)
{
void updateDetailTree() {
D.assert(!this.m_NeedSelectionUpdate);
if (!this.m_NeedDetailUpdate) {
if (m_DetailTreeView == null)
{
if (this.m_DetailTreeView == null) {
m_NeedDetailUpdate = false;
if (m_SelectedNodeRef == null)
{
m_DetailTreeView.node = null;
}
else
{
m_DetailTreeView.node = m_InspectorService.getDetailsSubtree(m_SelectedNodeRef, m_GroupName);
this.m_NeedDetailUpdate = false;
if (this.m_SelectedNodeRef == null) {
this.m_DetailTreeView.node = null;
} else {
this.m_DetailTreeView.node =
this.m_InspectorService.getDetailsSubtree(this.m_SelectedNodeRef, this.m_GroupName);
m_DetailTreeView.ExpandAll();
this.m_DetailTreeView.ExpandAll();
private void splitGUI(Rect splitterRect)
{
void splitGUI(Rect splitterRect) {
switch (Event.current.GetTypeForControl(id))
{
switch (Event.current.GetTypeForControl(id)) {
if (splitterRect.Contains(Event.current.mousePosition))
{
if (splitterRect.Contains(Event.current.mousePosition)) {
GUIUtility.hotControl = id;
Event.current.Use();
}

if (GUIUtility.hotControl == id)
{
m_SplitOffset += Event.current.delta.y;
m_Window.Repaint();
if (GUIUtility.hotControl == id) {
this.m_SplitOffset += Event.current.delta.y;
this.m_Window.Repaint();
if (GUIUtility.hotControl == id)
{
if (GUIUtility.hotControl == id) {
GUIUtility.hotControl = 0;
Event.current.Use();
}

}
[Serializable]
public class PanelState
{
public class PanelState {
public WidgetTreeType treeType;
public float splitOffset;
}

76
Runtime/debugger/inspector_objectgroup.cs


using System.Diagnostics;
using UnityEngine;
namespace Unity.UIWidgets.debugger
{
public class InspectorObjectGroupManager : Singleton<InspectorObjectGroupManager>
{
[SerializeField]
private int m_NextId = 0;
namespace Unity.UIWidgets.debugger {
public class InspectorObjectGroupManager : Singleton<InspectorObjectGroupManager> {
[SerializeField] int m_NextId = 0;
public string nextGroupName(string name)
{
return string.Format("pid{0}_{1}_{2}", Process.GetCurrentProcess().Id, name, m_NextId++);
public string nextGroupName(string name) {
return $"pid{Process.GetCurrentProcess().Id}_{name}_{this.m_NextId++}";
public class Singleton<T>: ScriptableObject where T : ScriptableObject
{
private static T m_Instance;
private static bool m_CreateNonSingletonInstance;
private bool m_IsNonSingletonInstance;
public static T Instance
{
get
{
if (m_Instance == null)
m_Instance = ScriptableObject.CreateInstance<T>();
public class Singleton<T> : ScriptableObject where T : ScriptableObject {
static T m_Instance;
static bool m_CreateNonSingletonInstance;
bool m_IsNonSingletonInstance;
public static T Instance {
get {
if (m_Instance == null) {
m_Instance = CreateInstance<T>();
}
private void OnEnable()
{
if (Singleton<T>.m_CreateNonSingletonInstance)
{
void OnEnable() {
if (m_CreateNonSingletonInstance) {
}
else if (this.m_IsNonSingletonInstance)
Object.DestroyImmediate((Object) this);
else if (m_Instance == null)
{
} else if (this.m_IsNonSingletonInstance) {
DestroyImmediate((Object) this);
} else if (m_Instance == null) {
}
else
{
Object.DestroyImmediate((Object) this);
} else {
DestroyImmediate((Object) this);
protected virtual void Initialize()
{
protected virtual void Initialize() {
public static T Create()
{
Singleton<T>.m_CreateNonSingletonInstance = true;
var instance = ScriptableObject.CreateInstance<T>();
Singleton<T>.m_CreateNonSingletonInstance = false;
public static T Create() {
m_CreateNonSingletonInstance = true;
var instance = CreateInstance<T>();
m_CreateNonSingletonInstance = false;
}
}

143
Runtime/debugger/inspector_service.cs


using Unity.UIWidgets.editor;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.debugger
{
namespace Unity.UIWidgets.debugger {
public class InspectorService
{
public class InspectorService {
private readonly WidgetInspectorService _widgetInspectorService;
readonly WidgetInspectorService _widgetInspectorService;
public InspectorService(WindowAdapter window)
{
public InspectorService(WindowAdapter window) {
_widgetInspectorService = window.widgetInspectorService;
_widgetInspectorService.developerInspect += this.developerInspect; // todo dispose
this._widgetInspectorService = window.widgetInspectorService;
this._widgetInspectorService.developerInspect += this.developerInspect; // todo dispose
public bool active
{
get { return window.alive; }
public bool active {
get { return this.window.alive; }
public void close()
{
setShowInspect(false);
_widgetInspectorService.developerInspect -= this.developerInspect;
public void close() {
this.setShowInspect(false);
this._widgetInspectorService.developerInspect -= this.developerInspect;
public DiagnosticsNode getRootWidgetSummaryTree(string groupName)
{
return toNode(window.WithBindingFunc(() =>_widgetInspectorService.getRootWidgetSummaryTree(groupName)));
public DiagnosticsNode getRootWidgetSummaryTree(string groupName) {
return this.toNode(this.window.withBindingFunc(() =>
this._widgetInspectorService.getRootWidgetSummaryTree(groupName)));
public DiagnosticsNode getRootWidget(string groupName)
{
return toNode(window.WithBindingFunc(() => _widgetInspectorService.getRootWidget(groupName)));
public DiagnosticsNode getRootWidget(string groupName) {
return this.toNode(this.window.withBindingFunc(() =>
this._widgetInspectorService.getRootWidget(groupName)));
public DiagnosticsNode getRootRenderObject(string groupName)
{
return toNode(window.WithBindingFunc(() =>_widgetInspectorService.getRootRenderObject(groupName)));
public DiagnosticsNode getRootRenderObject(string groupName) {
return this.toNode(this.window.withBindingFunc(() =>
this._widgetInspectorService.getRootRenderObject(groupName)));
public DiagnosticsNode getDetailsSubtree(InspectorInstanceRef instanceRef, string groupName)
{
return toNode(window.WithBindingFunc(()=> _widgetInspectorService.getDetailsSubtree(instanceRef.id, groupName)));
public DiagnosticsNode getDetailsSubtree(InspectorInstanceRef instanceRef, string groupName) {
return this.toNode(this.window.withBindingFunc(() =>
this._widgetInspectorService.getDetailsSubtree(instanceRef.id, groupName)));
public DiagnosticsNode getSelection(DiagnosticsNode previousSelection, WidgetTreeType treeType, bool localOnly, string groupName)
{
public DiagnosticsNode getSelection(DiagnosticsNode previousSelection, WidgetTreeType treeType, bool localOnly,
string groupName) {
window.WithBinding(() =>
{
switch (treeType)
{
this.window.withBinding(() => {
switch (treeType) {
? toNode(_widgetInspectorService.getSelectedSummaryWidget(previousSelectionId, groupName))
: toNode(_widgetInspectorService.getSelectedWidget(previousSelectionId, groupName));
? this.toNode(
this._widgetInspectorService.getSelectedSummaryWidget(previousSelectionId, groupName))
: this.toNode(
this._widgetInspectorService.getSelectedWidget(previousSelectionId, groupName));
result = toNode(
_widgetInspectorService.getSelectedRenderObject(previousSelectionId, groupName));
result = this.toNode(
this._widgetInspectorService.getSelectedRenderObject(previousSelectionId, groupName));
}
}
if (result != null && result.diagnosticRef == previousSelectionRef)
{
if (result != null && result.diagnosticRef == previousSelectionRef) {
}
else
{
} else {
public bool setSelection(InspectorInstanceRef inspectorInstanceRef, string groupName)
{
return window.WithBindingFunc(() => _widgetInspectorService.setSelectionById(inspectorInstanceRef.id, groupName));
public bool setSelection(InspectorInstanceRef inspectorInstanceRef, string groupName) {
return this.window.withBindingFunc(() =>
this._widgetInspectorService.setSelectionById(inspectorInstanceRef.id, groupName));
public void setShowInspect(bool show)
{
window.WithBinding(() =>
{
_widgetInspectorService.debugShowInspector = show;
});
public void setShowInspect(bool show) {
this.window.withBinding(() => { this._widgetInspectorService.debugShowInspector = show; });
public bool getShowInspect()
{
return window.WithBindingFunc(() => _widgetInspectorService.debugShowInspector);
public bool getShowInspect() {
return this.window.withBindingFunc(() => this._widgetInspectorService.debugShowInspector);
public List<DiagnosticsNode> getProperties(InspectorInstanceRef inspectorInstanceRef, string groupName)
{
var list = window.WithBindingFunc(() =>
_widgetInspectorService.getProperties(inspectorInstanceRef.id, groupName));
return list.Select(json => toNode(json, isProperty: true)).ToList();
public List<DiagnosticsNode> getProperties(InspectorInstanceRef inspectorInstanceRef, string groupName) {
var list = this.window.withBindingFunc(() =>
this._widgetInspectorService.getProperties(inspectorInstanceRef.id, groupName));
return list.Select(json => this.toNode(json, isProperty: true)).ToList();
public void disposeGroup(string groupName)
{
window.WithBinding(() => _widgetInspectorService.disposeGroup(groupName));
public void disposeGroup(string groupName) {
this.window.withBinding(() => this._widgetInspectorService.disposeGroup(groupName));
private DiagnosticsNode toNode(Dictionary<string, object> json, bool isProperty = false)
{
if (json == null)
{
DiagnosticsNode toNode(Dictionary<string, object> json, bool isProperty = false) {
if (json == null) {
return null;
}

private void developerInspect()
{
if (selectionChanged != null)
{
selectionChanged();
void developerInspect() {
if (this.selectionChanged != null) {
this.selectionChanged();
public enum WidgetTreeType
{
public enum WidgetTreeType {
}
}

168
Runtime/debugger/inspector_treeview.cs


using UnityEditor.IMGUI.Controls;
using UnityEngine;
namespace Unity.UIWidgets.debugger
{
public class InspectorTreeView : TreeView
{
private static int m_NextId = 0;
private DiagnosticsNode m_Node;
namespace Unity.UIWidgets.debugger {
public class InspectorTreeView : TreeView {
static int m_NextId = 0;
DiagnosticsNode m_Node;
private readonly Dictionary<InspectorInstanceRef, InspectorTreeItem> m_ValueToNode =
readonly Dictionary<InspectorInstanceRef, InspectorTreeItem> m_ValueToNode =
new Dictionary<InspectorInstanceRef, InspectorTreeItem>();
public delegate void NodeSelectionChanged(DiagnosticsNode node);

public InspectorTreeView(TreeViewState state) : base(state)
{
public InspectorTreeView(TreeViewState state) : base(state) {
setFieldValueRelection(this, new List<string> {"m_GUI", "m_UseHorizontalScroll"}, true);
useScrollView = true;
showBorder = true;
this.setFieldValueRelection(this, new List<string> {"m_GUI", "m_UseHorizontalScroll"}, true);
this.useScrollView = true;
this.showBorder = true;
public DiagnosticsNode node
{
set
{
m_Node = value;
Reload();
public DiagnosticsNode node {
set {
this.m_Node = value;
this.Reload();
get { return m_Node; }
get { return this.m_Node; }
public DiagnosticsNode selectedNode
{
get
{
var selection = GetSelection();
if (selection.Count <= 0)
{
public DiagnosticsNode selectedNode {
get {
var selection = this.GetSelection();
if (selection.Count <= 0) {
var item = FindItem(selection[0], rootItem) as InspectorTreeItem;
var item = this.FindItem(selection[0], this.rootItem) as InspectorTreeItem;
public InspectorTreeItem getTreeItemByValueRef(InspectorInstanceRef instanceRef, TreeViewItem from = null)
{
public InspectorTreeItem getTreeItemByValueRef(InspectorInstanceRef instanceRef, TreeViewItem from = null) {
m_ValueToNode.TryGetValue(instanceRef, out item);
this.m_ValueToNode.TryGetValue(instanceRef, out item);
protected override void RowGUI(TreeView.RowGUIArgs args)
{
protected override void RowGUI(RowGUIArgs args) {
if (item == null || item.node == null || !item.node.isProperty)
{
if (item == null || item.node == null || !item.node.isProperty) {
base.RowGUI(args);
return;
}

rect.xMin += GetContentIndent(item);
rect.xMin += this.GetContentIndent(item);
if (node.showName && !string.IsNullOrEmpty(node.name))
{
xoffset = labelGUI(xoffset, rect, string.Format("{0}{1} ", node.name, node.separator));
if (node.showName && !string.IsNullOrEmpty(node.name)) {
xoffset = this.labelGUI(xoffset, rect, $"{node.name}{node.separator} ");
if (node.isColorProperty)
{
if (Event.current.type == EventType.Repaint)
{
if (node.isColorProperty) {
if (Event.current.type == EventType.Repaint) {
var color = new UnityEngine.Color(red / 255.0f, green / 255.0f, blue / 255.0f, alpha / 255.0f);
var color = new Color(red / 255.0f, green / 255.0f, blue / 255.0f, alpha / 255.0f);
labelGUI(xoffset, rect, node.description);
this.labelGUI(xoffset, rect, node.description);
protected override void SelectionChanged(IList<int> selectedIds)
{
protected override void SelectionChanged(IList<int> selectedIds) {
if (selectedIds.Count > 0)
{
if (selectedIds.Count > 0) {
var item = FindItem(id, rootItem) as InspectorTreeItem;
if (item != null)
{
var item = this.FindItem(id, this.rootItem) as InspectorTreeItem;
if (item != null) {
if (onNodeSelectionChanged != null)
{
onNodeSelectionChanged(node);
if (this.onNodeSelectionChanged != null) {
this.onNodeSelectionChanged(node);
protected override TreeViewItem BuildRoot()
{
protected override TreeViewItem BuildRoot() {
m_ValueToNode.Clear();
this.m_ValueToNode.Clear();
if (m_Node != null)
{
root.AddChild(build(m_Node, false));
if (this.m_Node != null) {
root.AddChild(this.build(this.m_Node, false));
}
SetupDepthsFromParentsAndChildren(root);

private float labelGUI(float offset, Rect rowRect, string text)
{
float labelGUI(float offset, Rect rowRect, string text) {
float minWidth, maxWidth;
GUI.skin.label.CalcMinMaxWidth(new GUIContent(text), out minWidth, out maxWidth);
rowRect.xMin = offset;

}
private InspectorTreeItem build(DiagnosticsNode node, bool inProperty)
{
InspectorTreeItem build(DiagnosticsNode node, bool inProperty) {
if (!inProperty && node.valueRef != null)
{
m_ValueToNode[node.valueRef] = item;
if (!inProperty && node.valueRef != null) {
this.m_ValueToNode[node.valueRef] = item;
foreach (var propertyNode in node.inlineProperties)
{
item.AddChild(build(propertyNode, inProperty));
foreach (var propertyNode in node.inlineProperties) {
item.AddChild(this.build(propertyNode, inProperty));
foreach (var childNode in children)
{
item.AddChild(build(childNode, inProperty));
foreach (var childNode in children) {
item.AddChild(this.build(childNode, inProperty));
private void setFieldValueRelection(object obj, List<string> fields, object value)
{
for (var i = 0; i < fields.Count; ++i)
{
if (obj == null)
{
void setFieldValueRelection(object obj, List<string> fields, object value) {
for (var i = 0; i < fields.Count; ++i) {
if (obj == null) {
for (var type = obj.GetType(); type != null && fieldInfo == null; type = type.BaseType)
{
for (var type = obj.GetType(); type != null && fieldInfo == null; type = type.BaseType) {
if (fieldInfo == null)
{
if (fieldInfo == null) {
if (i + 1 < fields.Count)
{
if (i + 1 < fields.Count) {
}
else
{
} else {
fieldInfo.SetValue(obj, value);
}
}

public class InspectorTreeItem : TreeViewItem
{
public class InspectorTreeItem : TreeViewItem {
public InspectorTreeItem(DiagnosticsNode node, int id) : base(id)
{
public InspectorTreeItem(DiagnosticsNode node, int id) : base(id) {
public override string displayName
{
get { return node.name + node.description; }
public override string displayName {
get { return this.node.name + this.node.description; }
public static class Util
{
private const float colorIconMargin = 1.0f;
public static class Util {
const float colorIconMargin = 1.0f;
public static int GetIntProperty(Dictionary<string, object> properties, string name)
{
public static int GetIntProperty(Dictionary<string, object> properties, string name) {
object val = null;
if (properties != null) {

if (val == null)
{
if (val == null) {
return -1;
}

public static void DrawColorIcon(Rect rect, Color color)
{
public static void DrawColorIcon(Rect rect, Color color) {
var innerRect = new Rect(rect.x + colorIconMargin, rect.y + colorIconMargin,
rect.width - 2 * colorIconMargin,
rect.height - 2 * colorIconMargin);

198
Runtime/debugger/inspector_window.cs


using UnityEditor;
using UnityEngine;
namespace Unity.UIWidgets.debugger
{
public class WidgetsInpsectorWindow: EditorWindow
{
private InspectorService m_InspectorService;
private bool m_ShowInspect;
private readonly List<InspectorPanel> m_Panels = new List<InspectorPanel>();
private int m_PanelIndex = 0;
[SerializeField]
private List<PanelState> m_PanelStates = new List<PanelState>();
namespace Unity.UIWidgets.debugger {
public class WidgetsInpsectorWindow : EditorWindow {
InspectorService m_InspectorService;
bool m_ShowInspect;
readonly List<InspectorPanel> m_Panels = new List<InspectorPanel>();
int m_PanelIndex = 0;
[SerializeField] List<PanelState> m_PanelStates = new List<PanelState>();
public static void Init()
{
WidgetsInpsectorWindow window = (WidgetsInpsectorWindow)EditorWindow.GetWindow(typeof(WidgetsInpsectorWindow));
public static void Init() {
WidgetsInpsectorWindow window =
(WidgetsInpsectorWindow) GetWindow(typeof(WidgetsInpsectorWindow));
private void OnGUI()
{
void OnGUI() {
DoSelectDropDown();
if (m_InspectorService != null)
{
this.DoSelectDropDown();
if (this.m_InspectorService != null) {
var newShowInspect = GUILayout.Toggle(this.m_ShowInspect, new GUIContent("Inspect Element"), EditorStyles.toolbarButton);
if (EditorGUI.EndChangeCheck())
{
m_InspectorService.setShowInspect(newShowInspect);
var newShowInspect = GUILayout.Toggle(this.m_ShowInspect, new GUIContent("Inspect Element"),
EditorStyles.toolbarButton);
if (EditorGUI.EndChangeCheck()) {
this.m_InspectorService.setShowInspect(newShowInspect);
if (m_InspectorService != null)
{
if (this.m_InspectorService != null) {
m_Panels.Each((pannel, index) =>
{
if (GUILayout.Toggle(m_PanelIndex == index, pannel.title, EditorStyles.toolbarButton,
GUILayout.ExpandWidth(false), GUILayout.Width(100)))
{
m_PanelIndex = index;
this.m_Panels.Each((pannel, index) => {
if (GUILayout.Toggle(this.m_PanelIndex == index, pannel.title, EditorStyles.toolbarButton,
GUILayout.ExpandWidth(false), GUILayout.Width(100))) {
this.m_PanelIndex = index;
m_Panels[m_PanelIndex].OnGUI();
this.m_Panels[this.m_PanelIndex].OnGUI();
private void DoSelectDropDown()
{
var currentWindow = m_InspectorService == null ? null : m_InspectorService.window;
var selectTitle = currentWindow != null ? currentWindow.titleContent : new GUIContent("<Please Select>");
if (GUILayout.Button(selectTitle, EditorStyles.toolbarDropDown))
{
var windows = new List<WindowAdapter>(WindowAdapter.windowAdapters.Where(w =>
{
return w.WithBindingFunc(() => WidgetsBinding.instance.renderViewElement != null);
void DoSelectDropDown() {
var currentWindow = this.m_InspectorService == null ? null : this.m_InspectorService.window;
var selectTitle = currentWindow != null ? currentWindow.titleContent : new GUIContent("<Please Select>");
if (GUILayout.Button(selectTitle, EditorStyles.toolbarDropDown)) {
var windows = new List<WindowAdapter>(WindowAdapter.windowAdapters.Where(w => {
return w.withBindingFunc(() => WidgetsBinding.instance.renderViewElement != null);
Rect rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight, EditorStyles.toolbarDropDown);
Rect rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight,
EditorStyles.toolbarDropDown);
for (int i = 0; i < windows.Count; i++)
{
for (int i = 0; i < windows.Count; i++) {
if (windows[i] == currentWindow)
{
if (windows[i] == currentWindow) {
EditorUtility.DisplayCustomMenu(menuPos, labels, selectedIndex, (data, options, selected) =>
{
if (selected > 0)
{
EditorUtility.DisplayCustomMenu(menuPos, labels, selectedIndex, (data, options, selected) => {
if (selected > 0) {
if (selectedWindow != currentWindow)
{
inspect(selectedWindow);
if (selectedWindow != currentWindow) {
this.inspect(selectedWindow);
}
else
{
if (m_InspectorService != null)
{
closeInspect();
} else {
if (this.m_InspectorService != null) {
this.closeInspect();
}
}
}, null);

private void inspect(WindowAdapter window)
{
if (m_InspectorService != null) // stop previous inspect
void inspect(WindowAdapter window) {
if (this.m_InspectorService != null) // stop previous inspect
closeInspect();
this.closeInspect();
m_InspectorService = new InspectorService(window);
m_PanelIndex = 0;
this.m_InspectorService = new InspectorService(window);
this.m_PanelIndex = 0;
var state = m_PanelStates.Find((s) => s.treeType == WidgetTreeType.Widget);
m_Panels.Add(new InspectorPanel(this, WidgetTreeType.Widget, m_InspectorService,
state == null ? (float?)null : state.splitOffset));
state = m_PanelStates.Find((s) => s.treeType == WidgetTreeType.Render);
m_Panels.Add(new InspectorPanel(this, WidgetTreeType.Render, m_InspectorService,
state == null ? (float?)null : state.splitOffset));
var state = this.m_PanelStates.Find((s) => s.treeType == WidgetTreeType.Widget);
this.m_Panels.Add(new InspectorPanel(this, WidgetTreeType.Widget, this.m_InspectorService,
state == null ? (float?) null : state.splitOffset));
state = this.m_PanelStates.Find((s) => s.treeType == WidgetTreeType.Render);
this.m_Panels.Add(new InspectorPanel(this, WidgetTreeType.Render, this.m_InspectorService,
state == null ? (float?) null : state.splitOffset));
private void closeInspect()
{
if (m_InspectorService == null)
{
void closeInspect() {
if (this.m_InspectorService == null) {
m_InspectorService.close();
m_InspectorService = null;
foreach (var panel in m_Panels)
{
this.m_InspectorService.close();
this.m_InspectorService = null;
foreach (var panel in this.m_Panels) {
m_Panels.Clear();
m_ShowInspect = false;
this.m_Panels.Clear();
this.m_ShowInspect = false;
private void Update()
{
if (m_InspectorService != null && !m_InspectorService.active)
{
closeInspect();
Repaint();
void Update() {
if (this.m_InspectorService != null && !this.m_InspectorService.active) {
this.closeInspect();
this.Repaint();
if (m_InspectorService != null)
{
showInspect = m_InspectorService.getShowInspect();
if (this.m_InspectorService != null) {
showInspect = this.m_InspectorService.getShowInspect();
if (showInspect != this.m_ShowInspect)
{
Repaint();
if (showInspect != this.m_ShowInspect) {
this.Repaint();
m_ShowInspect = showInspect;
this.m_ShowInspect = showInspect;
for (int i = 0; i < m_Panels.Count; i++)
{
m_Panels[i].visibleToUser = m_PanelIndex == i;
m_Panels[i].Update();
for (int i = 0; i < this.m_Panels.Count; i++) {
this.m_Panels[i].visibleToUser = this.m_PanelIndex == i;
this.m_Panels[i].Update();
if (m_Panels.Count > 0)
{
m_PanelStates = m_Panels.Select(p => p.PanelState).ToList();
if (this.m_Panels.Count > 0) {
this.m_PanelStates = this.m_Panels.Select(p => p.PanelState).ToList();
void OnDestroy()
{
closeInspect();
void OnDestroy() {
this.closeInspect();
}
}
}
#endif

55
Runtime/editor/editor_window.cs


using System.Diagnostics;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.service;
using Unity.UIWidgets.service;
using UnityEditor;
using UnityEditor;
wantsMouseMove = true;
wantsMouseEnterLeaveWindow = true;
this.wantsMouseMove = true;
this.wantsMouseEnterLeaveWindow = true;
}
void OnEnable() {

}
public class EditorWindowAdapter : WindowAdapter {
public readonly EditorWindow editorWindow;
public EditorWindowAdapter(EditorWindow editorWindow) {

public override void scheduleFrame(bool regenerateLayerTree = true) {
base.scheduleFrame(regenerateLayerTree);
editorWindow.Repaint();
this.editorWindow.Repaint();
get { return editorWindow.titleContent; }
get { return this.editorWindow.titleContent; }
}
protected override double queryDevicePixelRatio() {

protected override Vector2 queryWindowSize() {
return editorWindow.position.size;
return this.editorWindow.position.size;
}
}

public static IEnumerable<WindowAdapter> windowAdapters {
get { return _windowAdapters; }
}

}
public void OnEnable() {
this._devicePixelRatio = queryDevicePixelRatio();
var size = queryWindowSize();
this._devicePixelRatio = this.queryDevicePixelRatio();
var size = this.queryWindowSize();
this._lastWindowWidth = size.x;
this._lastWindowHeight = size.y;
this._physicalSize = new Size(

D.assert(this._surface == null);
this._surface = createSurface();
this._surface = this.createSurface();
this._rasterizer.setup(this._surface);
_windowAdapters.Add(this);

}
}
public void PostPointerEvent(List<PointerData> data) {
WithBinding(() => {
this.onPointerEvent(new PointerDataPacket(data));
});
public void postPointerEvents(List<PointerData> data) {
this.withBinding(() => { this.onPointerEvent(new PointerDataPacket(data)); });
public void PostPointerEvent(PointerData data) {
PostPointerEvent(new List<PointerData>() { data });
public void postPointerEvent(PointerData data) {
this.postPointerEvents(new List<PointerData>() {data});
public void WithBinding(Action fn) {
public void withBinding(Action fn) {
public T WithBindingFunc<T>(Func<T> fn) {
public T withBindingFunc<T>(Func<T> fn) {
using (this.getScope()) {
return fn();
}

evt = evt??Event.current;
evt = evt ?? Event.current;
if (this._devicePixelRatio != queryDevicePixelRatio()) {
if (this._devicePixelRatio != this.queryDevicePixelRatio()) {
var size = queryWindowSize();
var size = this.queryWindowSize();
if (this._lastWindowWidth != size.x
|| this._lastWindowHeight != size.y) {
dirty = true;

this._devicePixelRatio = queryDevicePixelRatio();
this._devicePixelRatio = this.queryDevicePixelRatio();
this._lastWindowWidth = size.x;
this._lastWindowHeight = size.y;
this._physicalSize = new Size(

}
void _doOnGUI(Event evt) {
if (evt.type == EventType.Repaint) {
if (this._regenerateLayerTree) {
this._regenerateLayerTree = false;

}
}
if (_textInput != null) {
_textInput.OnGUI();
if (this._textInput != null) {
this._textInput.OnGUI();
}
}

get { return this._textInput; }
}
}
}
}

2
Runtime/editor/rasterizer.cs


callback();
}
}
}
}

22
Runtime/editor/surface.cs


using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Object = UnityEngine.Object;
using Rect = UnityEngine.Rect;
namespace Unity.UIWidgets.editor {

static Material _uiDefaultMat;
public delegate void DrawToTargetFunc(Rect screenRect, Texture texture, Material mat);
internal static Material _getGUITextureMat() {
if (_guiTextureMat) {
return _guiTextureMat;

_guiTextureMat.hideFlags = HideFlags.HideAndDontSave;
return _guiTextureMat;
}
internal static Material _getUIDefaultMat() {
if (_uiDefaultMat) {
return _uiDefaultMat;

GrSurface _surface;
private DrawToTargetFunc _drawToTargetFunc;
public EditorWindowSurface(DrawToTargetFunc drawToTargetFunc = null)
{
DrawToTargetFunc _drawToTargetFunc;
public EditorWindowSurface(DrawToTargetFunc drawToTargetFunc = null) {
this._drawToTargetFunc = drawToTargetFunc;
}

(float) (this._surface.size.height / this._surface.devicePixelRatio));
if (this._drawToTargetFunc == null) {
Graphics.DrawTexture(screenRect, this._surface.getRenderTexture(), _getGUITextureMat());
Graphics.DrawTexture(screenRect, this._surface.getRenderTexture(),
_getGUITextureMat());
this._drawToTargetFunc(screenRect, this._surface.getRenderTexture(), _getUIDefaultMat());
this._drawToTargetFunc(screenRect, this._surface.getRenderTexture(),
_getUIDefaultMat());
}
return true;
}

autoGenerateMips = false,
};
if (QualitySettings.antiAliasing != 0)
{
if (QualitySettings.antiAliasing != 0) {
desc.msaaSamples = QualitySettings.antiAliasing;
}

}
}
}
}
}

198
Runtime/engine/WidgetCanvas.cs


using RawImage = UnityEngine.UI.RawImage;
using Rect = UnityEngine.Rect;
namespace Unity.UIWidgets.engine
{
public class UIWidgetWindowAdapter : WindowAdapter
{
private WidgetCanvas _widgetCanvas;
private bool _needsPaint;
namespace Unity.UIWidgets.engine {
public class UIWidgetWindowAdapter : WindowAdapter {
readonly WidgetCanvas _widgetCanvas;
bool _needsPaint;
_needsPaint = true;
this._needsPaint = true;
public UIWidgetWindowAdapter(WidgetCanvas widgetCanvas)
{
public UIWidgetWindowAdapter(WidgetCanvas widgetCanvas) {
public override void OnGUI(Event evt)
{
if (evt.type == EventType.Repaint)
{
if (!_needsPaint)
{
public override void OnGUI(Event evt) {
if (evt.type == EventType.Repaint) {
if (!this._needsPaint) {
_needsPaint = false;
this._needsPaint = false;
protected override Surface createSurface()
{
return new EditorWindowSurface(_widgetCanvas.applyRenderTexture);
protected override Surface createSurface() {
return new EditorWindowSurface(this._widgetCanvas.applyRenderTexture);
public override GUIContent titleContent
{
get { return new GUIContent(_widgetCanvas.gameObject.name); }
public override GUIContent titleContent {
get { return new GUIContent(this._widgetCanvas.gameObject.name); }
protected override double queryDevicePixelRatio()
{
return _widgetCanvas.canvas.scaleFactor;
protected override double queryDevicePixelRatio() {
return this._widgetCanvas.canvas.scaleFactor;
protected override Vector2 queryWindowSize()
{
return _widgetCanvas.rectTransform.rect.size;
protected override Vector2 queryWindowSize() {
return this._widgetCanvas.rectTransform.rect.size;
IPointerEnterHandler, IPointerExitHandler
{
private static Event _repaintEvent;
private WindowAdapter _windowAdapter;
private Texture _texture;
private Vector2 _lastMouseMove;
private bool _mouseEntered;
protected override void OnEnable()
{
IPointerEnterHandler, IPointerExitHandler {
static Event _repaintEvent;
WindowAdapter _windowAdapter;
Texture _texture;
Vector2 _lastMouseMove;
bool _mouseEntered;
protected override void OnEnable() {
base.OnEnable();
if (_repaintEvent == null) {

D.assert(this._windowAdapter == null);
_windowAdapter = new UIWidgetWindowAdapter(this);
_windowAdapter.OnEnable();
var root = new WidgetsApp(home: getWidget(), window: _windowAdapter);
_windowAdapter.attachRootWidget(root);
_lastMouseMove = Input.mousePosition;
this._windowAdapter = new UIWidgetWindowAdapter(this);
this._windowAdapter.OnEnable();
var root = new WidgetsApp(home: this.getWidget(), window: this._windowAdapter);
this._windowAdapter.attachRootWidget(root);
this._lastMouseMove = Input.mousePosition;
protected override void OnDisable()
{
protected override void OnDisable() {
D.assert(this._windowAdapter != null);
this._windowAdapter.OnDisable();
this._windowAdapter = null;

this.material = mat;
}
private void Update()
{
if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != gameObject)
{
unfocusIfNeeded();
void Update() {
if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != this.gameObject) {
this.unfocusIfNeeded();
if (_mouseEntered && (_lastMouseMove.x != Input.mousePosition.x || _lastMouseMove.y != Input.mousePosition.y))
{
if (this._mouseEntered && (this._lastMouseMove.x != Input.mousePosition.x ||
this._lastMouseMove.y != Input.mousePosition.y)) {
_lastMouseMove = Input.mousePosition;
this._lastMouseMove = Input.mousePosition;
private void OnGUI()
{
if (Event.current.type == EventType.KeyDown || Event.current.type == EventType.KeyUp)
{
void OnGUI() {
if (Event.current.type == EventType.KeyDown || Event.current.type == EventType.KeyUp) {
private void OnMouseOver()
{
var pos = getPointPosition(Input.mousePosition);
this._windowAdapter.PostPointerEvent(new PointerData(
void OnMouseOver() {
var pos = this.getPointPosition(Input.mousePosition);
this._windowAdapter.postPointerEvent(new PointerData(
device: getMouseButtonDown(),
device: this.getMouseButtonDown(),
private int getMouseButtonDown()
{
for (int key = 0; key < 3; key++)
{
if (Input.GetMouseButton(key))
{
int getMouseButtonDown() {
for (int key = 0; key < 3; key++) {
if (Input.GetMouseButton(key)) {
return key;
}
}

public void OnPointerDown(PointerEventData eventData)
{
EventSystem.current.SetSelectedGameObject(gameObject, eventData);
var position = getPointPosition(eventData);
this._windowAdapter.PostPointerEvent(new PointerData(
public void OnPointerDown(PointerEventData eventData) {
EventSystem.current.SetSelectedGameObject(this.gameObject, eventData);
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.down,
kind: PointerDeviceKind.mouse,

));
}
public void OnPointerUp(PointerEventData eventData)
{
var position = getPointPosition(eventData);
this._windowAdapter.PostPointerEvent(new PointerData(
public void OnPointerUp(PointerEventData eventData) {
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.up,
kind: PointerDeviceKind.mouse,

));
}
public Vector2 getPointPosition(PointerEventData eventData)
{
public Vector2 getPointPosition(PointerEventData eventData) {
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.position,
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rectTransform, eventData.position,
localPoint.x = localPoint.x - rectTransform.rect.min.x;
localPoint.y = rectTransform.rect.max.y - localPoint.y;
localPoint.x = localPoint.x - this.rectTransform.rect.min.x;
localPoint.y = this.rectTransform.rect.max.y - localPoint.y;
public Vector2 getPointPosition(Vector2 position)
{
public Vector2 getPointPosition(Vector2 position) {
if (canvas.renderMode != RenderMode.ScreenSpaceCamera)
{
eventCamera = canvas.GetComponent<GraphicRaycaster>().eventCamera;
if (this.canvas.renderMode != RenderMode.ScreenSpaceCamera) {
eventCamera = this.canvas.GetComponent<GraphicRaycaster>().eventCamera;
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, position,
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rectTransform, position,
localPoint.x = localPoint.x - rectTransform.rect.min.x;
localPoint.y = rectTransform.rect.max.y - localPoint.y;
localPoint.x = localPoint.x - this.rectTransform.rect.min.x;
localPoint.y = this.rectTransform.rect.max.y - localPoint.y;
public void OnDrag(PointerEventData eventData)
{
var position = getPointPosition(eventData);
this._windowAdapter.PostPointerEvent(new PointerData(
public void OnDrag(PointerEventData eventData) {
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.move,
kind: PointerDeviceKind.mouse,

));
}
public void OnPointerEnter(PointerEventData eventData)
{
_mouseEntered = true;
_lastMouseMove = eventData.position;
var position = getPointPosition(eventData);
this._windowAdapter.PostPointerEvent(new PointerData(
public void OnPointerEnter(PointerEventData eventData) {
this._mouseEntered = true;
this._lastMouseMove = eventData.position;
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: PointerDeviceKind.mouse,

));
}
public void OnPointerExit(PointerEventData eventData)
{
_mouseEntered = false;
var position = getPointPosition(eventData);
this._windowAdapter.PostPointerEvent(new PointerData(
public void OnPointerExit(PointerEventData eventData) {
this._mouseEntered = false;
var position = this.getPointPosition(eventData);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.hover,
kind: PointerDeviceKind.mouse,

));
}
private void unfocusIfNeeded()
{
using (_windowAdapter.getScope())
{
void unfocusIfNeeded() {
using (this._windowAdapter.getScope()) {
if (focusNode != null)
{
if (focusNode != null) {
}
}

8
Runtime/flow/clip_rect_layer.cs


using Unity.UIWidgets.ui;
using Rect = Unity.UIWidgets.ui.Rect;
private Rect _clipRect;
Rect _clipRect;
public Rect clipRect {
set { this._clipRect = value; }

try {
this.paintChildren(context);
}
finally {
} finally {
}
}

10
Runtime/flow/clip_rrect_layer.cs


using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
using Color = Unity.UIWidgets.ui.Color;
private RRect _clipRRect;
RRect _clipRRect;
public RRect clipRRect {
set { this._clipRRect = value; }

try {
this.paintChildren(context);
}
finally {
} finally {
}
}

5
Runtime/flow/compositor_context.cs


using System;
using Unity.UIWidgets.editor;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.flow {

public RasterCache rasterCache() {
return this._rasterCache;
}
void _beginFrame(ScopedFrame frame) {
}

}
}
}

4
Runtime/flow/container_layer.cs


namespace Unity.UIWidgets.flow {
public abstract class ContainerLayer : Layer {
private readonly List<Layer> _layers = new List<Layer>();
readonly List<Layer> _layers = new List<Layer>();
public List<Layer> layers {
get { return this._layers; }

}
}
}
}
}

9
Runtime/flow/layer.cs


using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
using Canvas = Unity.UIWidgets.ui.Canvas;
namespace Unity.UIWidgets.flow {
public class PrerollContext {

}
public abstract class Layer {
private ContainerLayer _parent;
ContainerLayer _parent;
public ContainerLayer parent {
get { return this._parent; }

private Rect _paintBounds = Rect.zero;
Rect _paintBounds = Rect.zero;
public Rect paintBounds {
get { return this._paintBounds; }

public abstract void paint(PaintContext context);
}
}
}

5
Runtime/flow/layer_tree.cs


using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.flow {
public class LayerTree {

}
double _devicePixelRatio;
public double devicePixelRatio {
get { return this._devicePixelRatio; }
set { this._devicePixelRatio = value; }

}
}
}
}
}

2
Runtime/flow/matrix_decomposition.cs


public readonly Vector4 perspective;
public readonly Vector4 rotation;
}
}
}

7
Runtime/flow/opacity_layer.cs


namespace Unity.UIWidgets.flow {
public class OpacityLayer : ContainerLayer {
private int _alpha;
int _alpha;
public int alpha {
set { this._alpha = value; }

canvas.saveLayer(this.paintBounds, paint);
try {
this.paintChildren(context);
}
finally {
} finally {
}
}

18
Runtime/flow/picture_layer.cs


using Unity.UIWidgets.ui;
using UnityEngine;
private Offset _offset;
Offset _offset;
private Picture _picture;
Picture _picture;
private bool _isComplex = false;
bool _isComplex = false;
private bool _willChange = false;
bool _willChange = false;
private RasterCacheResult _rasterCacheResult;
RasterCacheResult _rasterCacheResult;
ctm.preConcat(matrix);
ctm.preConcat(matrix);
ctm[6] = ctm[6].alignToPixel(context.devicePixelRatio);
ctm[7] = ctm[7].alignToPixel(context.devicePixelRatio);

} else {
canvas.drawPicture(this._picture);
}
}
finally {
} finally {
}
}

34
Runtime/flow/raster_cache.cs


return true;
});
}
finally {
} finally {
canvas.restore();
}
}

public readonly float devicePixelRatio;
public bool Equals(_RasterCacheKey other) {
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.picture, other.picture) &&
Equals(this.matrix, other.matrix) &&
this.devicePixelRatio.Equals(other.devicePixelRatio);

if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((_RasterCacheKey) obj);
}

Mathf.CeilToInt((float) (bounds.width * devicePixelRatio)),
Mathf.CeilToInt((float) (bounds.height * devicePixelRatio)),
RenderTextureFormat.Default, 24) {
msaaSamples = QualitySettings.antiAliasing,
if (QualitySettings.antiAliasing != 0) {
desc.msaaSamples = QualitySettings.antiAliasing;
}
var canvas = new CommandBufferCanvas(renderTexture, devicePixelRatio);
canvas.translate((float) -bounds.left, (float) -bounds.top);
canvas.concat(transform);

this._cache.Clear();
}
}
}
}

7
Runtime/flow/transform_layer.cs


namespace Unity.UIWidgets.flow {
public class TransformLayer : ContainerLayer {
private Matrix3 _tranform;
Matrix3 _tranform;
public Matrix3 transform {
set { this._tranform = value; }

try {
canvas.concat(this._tranform);
this.paintChildren(context);
}
finally {
} finally {
}
}

8
Runtime/foundation/assertions.cs


using System.Collections.Generic;
using System.Linq;
using System.Text;
using Debug = UnityEngine.Debug;
using UnityEngine;
namespace Unity.UIWidgets.foundation {
public delegate void UIWidgetsExceptionHandler(UIWidgetsErrorDetails details);

Exception exception = null,
string library = "UIWidgets framework",
string context = null,
EnumerableFilter<String> stackFilter = null,
EnumerableFilter<string> stackFilter = null,
InformationCollector informationCollector = null,
bool silent = false
) {

public readonly Exception exception;
public readonly string library;
public readonly string context;
public readonly EnumerableFilter<String> stackFilter;
public readonly EnumerableFilter<string> stackFilter;
public readonly InformationCollector informationCollector;
public readonly bool silent;

}
}
}
}
}

8
Runtime/foundation/basic_types.cs


using Object = UnityEngine.Object;
namespace Unity.UIWidgets.foundation {
public delegate void ValueChanged<T>(T value);
public delegate IEnumerable<T> EnumerableFilter<T>(IEnumerable<T> input);

public static bool isNotEmpty(this string it) {
return !string.IsNullOrEmpty(it);
}
public static TValue getOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> it, TKey key)
{
public static TValue getOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> it, TKey key) {
}
}

2
Runtime/foundation/binding.cs


namespace Unity.UIWidgets.foundation {
}
}

2
Runtime/foundation/callback.cs


namespace Unity.UIWidgets.foundation {
}
}

8
Runtime/foundation/change_notifier.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.foundation {
public interface Listenable {

if (this._listeners.Contains(listener)) {
listener();
}
}
catch (Exception ex) {
} catch (Exception ex) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: ex,
library: "foundation library",

public T value {
get { return this._value; }
set {
if (object.Equals(value, this._value)) {
if (Equals(value, this._value)) {
return;
}

return Diagnostics.describeIdentity(this) + "(" + this._value + ")";
}
}
}
}

17
Runtime/foundation/debug.cs


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

D.assert(result(), message);
assert(result(), message);
}
[Conditional("UIWidgets_DEBUG")]

public static bool debugRepaintRainbowEnabled = false;
public static bool debugPaintLayerBordersEnabled = false;
// public static Color debugCurrentRepaintColor = Color.fromfromAHSV(0.4, 60.0, 1.0, 1.0);;
public static void _debugDrawDoubleRect(Canvas canvas, Rect outerRect, Rect innerRect, Color color) {

}
public static void debugPaintPadding(Canvas canvas, Rect outerRect, Rect innerRect, double outlineWidth = 2.0) {
D.assert(() => {
assert(() => {
if (innerRect != null && !innerRect.isEmpty) {
_debugDrawDoubleRect(canvas, outerRect, innerRect, new Color(0x900090FF));
} else {

}
}
}
}
}

75
Runtime/foundation/diagnostics.cs


{"name", this.name},
{"showSeparator", this.showSeparator},
{"description", this.toDescription()},
{"level", Convert.ToString(this.level)},
{"level", Convert.ToString(this.level)},
{"style", Convert.ToString(this.style)},
{"valueToString", Convert.ToString(valueObject)},
{"style", Convert.ToString(this.style)},
{"valueToString", Convert.ToString(this.valueObject)},
{"type", this.GetType().ToString()},
{"hasChildren", this.getChildren().isNotEmpty()}
};

config.addBlankLineIfNoChildren &&
builder.hasMultipleLines) {
string prefix = prefixChildren.TrimEnd();
if (prefix.isNotEmpty())
if (prefix.isNotEmpty()) {
}
}
if (children.isNotEmpty() && config.showChildren) {

}
public class MessageProperty : DiagnosticsProperty<object> {
public MessageProperty(String name, String message,
public MessageProperty(string name, string message,
DiagnosticLevel level = DiagnosticLevel.info
) : base(name, null, description: message, level: level) {
D.assert(name != null);

string ifNull = null,
string unit = null,
bool showName = true,
Object defaultValue = null,
object defaultValue = null,
string tooltip = null,
DiagnosticLevel level = DiagnosticLevel.info
) : base(

}
public class IntProperty : _NumProperty<int?> {
public IntProperty(String name, int? value,
String ifNull = null,
public IntProperty(string name, int? value,
string ifNull = null,
String unit = null,
Object defaultValue = null,
string unit = null,
object defaultValue = null,
DiagnosticLevel level = DiagnosticLevel.info
) : base(
name,

) {
}
protected override String numberToString() {
protected override string numberToString() {
if (this.value == null) {
return "null";
}

) {
}
private DoubleProperty(
DoubleProperty(
string name,
ComputePropertyValueCallback<double?> computeValue,
string ifNull = null,

public override bool showName {
get {
if (this.value == null || this.value == true && this.ifTrue == null || this.value == false && this.ifFalse == null) {
if (this.value == null || this.value == true && this.ifTrue == null ||
this.value == false && this.ifFalse == null) {
return true;
}

public class EnumProperty<T> : DiagnosticsProperty<T> {
public EnumProperty(String name, T value,
Object defaultValue = null,
public EnumProperty(string name, T value,
object defaultValue = null,
DiagnosticLevel level = DiagnosticLevel.info
) : base(
name,

}
public class ObjectFlagProperty<T> : DiagnosticsProperty<T> {
public ObjectFlagProperty(String name, T value,
public ObjectFlagProperty(string name, T value,
String ifNull = null,
string ifNull = null,
bool showName = false,
DiagnosticLevel level = DiagnosticLevel.info
) : base(

D.assert(ifPresent != null || ifNull != null);
}
private ObjectFlagProperty(
String name,
ObjectFlagProperty(
string name,
T value,
DiagnosticLevel level = DiagnosticLevel.info
) : base(

}
public static ObjectFlagProperty<T> has(
String name,
string name,
T value,
DiagnosticLevel level = DiagnosticLevel.info
) {

}
}
public override Dictionary<String, Object> toJsonMap() {
public override Dictionary<string, object> toJsonMap() {
var json = base.toJsonMap();
if (this.ifPresent != null) {
json["ifPresent"] = this.ifPresent;

}
public delegate T ComputePropertyValueCallback<T>();
public class DiagnosticsProperty<T> : DiagnosticsNode {
public DiagnosticsProperty(
string name,

public override Dictionary<string, object> toJsonMap() {
var json = base.toJsonMap();
if (this.defaultValue != Diagnostics.kNoDefaultValue) {
json["defaultValue"] = Convert.ToString(this.defaultValue);
json["defaultValue"] = Convert.ToString(this.defaultValue);
}
if (this.ifEmpty != null) {

json["propertyType"] = this.propertyType.ToString();
json["valueToString"] = this.valueToString();
json["defaultLevel"] = Convert.ToString(this._defaultLevel);
json["defaultLevel"] = Convert.ToString(this._defaultLevel);
if (typeof(Diagnosticable).IsAssignableFrom(typeof(T))) {
json["isDiagnosticableValue"] = true;
}

this._valueComputed = true;
try {
this._value = this._computeValue();
}
catch (Exception ex) {
} catch (Exception ex) {
this._exception = ex;
this._value = default(T);
}

return DiagnosticLevel.warning;
}
if (this.defaultValue != Diagnostics.kNoDefaultValue && object.Equals(this.value, this.defaultValue)) {
if (this.defaultValue != Diagnostics.kNoDefaultValue && Equals(this.value, this.defaultValue)) {
return DiagnosticLevel.fine;
}

public class DiagnosticableNode<T> : DiagnosticsNode where T : Diagnosticable {
public DiagnosticableNode(
String name = null,
string name = null,
T value = null,
DiagnosticsTreeStyle? style = null
) : base(name: name, style: style) {

return new List<DiagnosticsNode>();
}
public override String toDescription(
public override string toDescription(
TextTreeConfiguration parentConfiguration = null
) {
return this._value.toStringShort();

}
public virtual DiagnosticsNode toDiagnosticsNode(
String name = null,
string name = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse) {
return new DiagnosticableNode<Diagnosticable>(
name: name, value: this, style: style

}
public virtual string toStringShallow(
String joiner = ", ",
string joiner = ", ",
DiagnosticLevel minLevel = DiagnosticLevel.debug
) {
var result = new StringBuilder();

}
public virtual string toStringDeep(
String prefixLineOne = "",
String prefixOtherLines = null,
string prefixLineOne = "",
string prefixOtherLines = null,
DiagnosticLevel minLevel = DiagnosticLevel.debug
) {
return this.toDiagnosticsNode().toStringDeep(

}
public override DiagnosticsNode toDiagnosticsNode(
String name = null,
string name = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse) {
return new _DiagnosticableTreeNode(
name: name,

);
internal static readonly _NoDefaultValue kNoDefaultValue = new _NoDefaultValue();
public static readonly object kNullDefaultValue = new _NullDefaultValue();
public static string shortHash(object o) {

public static string describeIdentity(object o) {
return string.Format("{0}#{1}", o.GetType(), Diagnostics.shortHash(o));
return $"{o.GetType()}#{shortHash(o)}";
}
}

30
Runtime/foundation/key.cs


public readonly T value;
public bool Equals(ValueKey<T> other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ValueKey<T>) obj);
}

public static bool operator ==(ValueKey<T> left, ValueKey<T> right) {
return object.Equals(left, right);
return Equals(left, right);
return !object.Equals(left, right);
return !Equals(left, right);
}
public override string ToString() {

return string.Format("[{0}]", valueString);
return $"[{valueString}]";
return string.Format("[{0} {1}]", this.GetType(), valueString);
return $"[{this.GetType()} {valueString}]";
}
}

32
Runtime/foundation/node.cs


this._type = type;
var fields = _getTypeFields(type);
this._list = new List<object>(fields.Length);
foreach (var field in fields) {
this._list.Add(field.GetValue(target));

return fields;
}
static bool _sequenceEquals(IList list1, IList list2) {
if (list1 == null && list2 == null) {
return true;

return false;
}
} else {
if (!object.Equals(item1, item2)) {
if (!Equals(item1, item2)) {
return false;
}
}

}
public bool Equals(_DependencyList other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((_DependencyList) obj);
}

}
public static bool operator ==(_DependencyList left, _DependencyList right) {
return object.Equals(left, right);
return Equals(left, right);
return !object.Equals(left, right);
return !Equals(left, right);
}
}

10
Runtime/foundation/node.mixin.gen.cs


}
~CanonicalMixinDiagnosticableTree() {
if (object.ReferenceEquals(this, this._canonical)) {
if (ReferenceEquals(this, this._canonical)) {
Timer.runInMain(() => { _canonicalObjects.Remove(dependencyList); });
Timer.runInMainFromFinalizer(() => { _canonicalObjects.Remove(dependencyList); });
}
}
}

public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) {
if (ReferenceEquals(null, obj)) {
if (object.ReferenceEquals(this, obj)) {
if (ReferenceEquals(this, obj)) {
return true;
}

return object.ReferenceEquals(this._getCanonical(), ((CanonicalMixinDiagnosticableTree) obj)._getCanonical());
return ReferenceEquals(this._getCanonical(), ((CanonicalMixinDiagnosticableTree) obj)._getCanonical());
}
public override int GetHashCode() {

10
Runtime/foundation/node.mixin.njk


}
~CanonicalMixin{{with}}() {
if (object.ReferenceEquals(this, this._canonical)) {
if (ReferenceEquals(this, this._canonical)) {
Timer.runInMain(() => { _canonicalObjects.Remove(dependencyList); });
Timer.runInMainFromFinalizer(() => { _canonicalObjects.Remove(dependencyList); });
}
}
}

public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) {
if (ReferenceEquals(null, obj)) {
if (object.ReferenceEquals(this, obj)) {
if (ReferenceEquals(this, obj)) {
return true;
}

return object.ReferenceEquals(this._getCanonical(), ((CanonicalMixin{{with}}) obj)._getCanonical());
return ReferenceEquals(this._getCanonical(), ((CanonicalMixin{{with}}) obj)._getCanonical());
}
public override int GetHashCode() {

2
Runtime/foundation/observer_list.cs


get { return false; }
}
}
}
}

8
Runtime/foundation/print.cs


addPrefix = true;
}
if (lastWordEnd >= message.Length)
if (lastWordEnd >= message.Length) {
}
while ((index < message.Length) && (message[index] == ' '))
while ((index < message.Length) && (message[index] == ' ')) {
}
start = index;
mode = _WordWrapParseMode.inWord;
} else {

}
}
}
}
}

20
Runtime/gestures/arena.cs


} else {
buffer.Append(string.Join(", ", this.members.Select(
member => member == this.eagerWinner
? string.Format("{0} (eager winner)", member)
? $"{member} (eager winner)"
: member.ToString()).ToArray()));
}

state.add(member);
D.assert(this._debugLogDiagnostic(pointer, string.Format("Adding: {0}", member)));
D.assert(this._debugLogDiagnostic(pointer, $"Adding: {member}"));
return new GestureArenaEntry(this, pointer, member);
}

this._arenas.Remove(pointer);
if (state.members.isNotEmpty()) {
D.assert(this._debugLogDiagnostic(
pointer, string.Format("Winner: {0}", state.members.First())));
pointer, $"Winner: {state.members.First()}"));
state.members.First().acceptGesture(pointer);
for (int i = 1; i < state.members.Count; i++) {

}
D.assert(this._debugLogDiagnostic(pointer,
string.Format("{0}: {1}",
disposition == GestureDisposition.accepted ? "Accepting" : "Rejecting",
member)));
$"{(disposition == GestureDisposition.accepted ? "Accepting" : "Rejecting")}: {member}"));
D.assert(state.members.Contains(member));
if (disposition == GestureDisposition.rejected) {

state.eagerWinner = state.eagerWinner ?? member;
} else {
D.assert(this._debugLogDiagnostic(pointer,
string.Format("Self-declared winner: {0}", member)));
$"Self-declared winner: {member}"));
this._resolveInFavorOf(pointer, state, member);
}
}

D.assert(this._debugLogDiagnostic(pointer, "Arena empty."));
} else if (state.eagerWinner != null) {
D.assert(this._debugLogDiagnostic(pointer,
string.Format("Eager winner: {0}", state.eagerWinner)));
$"Eager winner: {state.eagerWinner}"));
this._resolveInFavorOf(pointer, state, state.eagerWinner);
}
}

D.assert(members.Count == 1);
this._arenas.Remove(pointer);
D.assert(this._debugLogDiagnostic(pointer,
string.Format("Default winner: {0}", state.members.First())));
$"Default winner: {state.members.First()}"));
state.members.First().acceptGesture(pointer);
}

Debug.LogFormat("Gesture arena {0} ❙ {1}{2}",
pointer.ToString().PadRight(4),
message,
count != null ? string.Format(" with {0} member{1}.", count, s) : "");
count != null ? $" with {count} member{s}." : "");
}
return true;

}
}
}
}

62
Runtime/gestures/binding.cs


using System.Collections.Generic;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using UnityEngine;

public static new GestureBinding instance {
public new static GestureBinding instance {
get { return (GestureBinding) SchedulerBinding.instance; }
set { SchedulerBinding.instance = value; }
}

}
readonly Queue<PointerEvent> _pendingPointerEvents = new Queue<PointerEvent>();
void _handlePointerDataPacket(PointerDataPacket packet) {
foreach (var pointerEvent in PointerEventConverter.expand(packet.data, Window.instance.devicePixelRatio)) {
this._pendingPointerEvents.Enqueue(pointerEvent);

public readonly GestureArenaManager gestureArena;
public readonly Dictionary<int, HitTestResult> _hitTests = new Dictionary<int, HitTestResult>();
if (evt is PointerHoverEvent || evt is PointerMoveEvent)
{
if (evt is PointerHoverEvent || evt is PointerMoveEvent) {
this._hitTests[evt.pointer] = result;
D.assert(() => {
if (D.debugPrintHitTestResults) {

}
}
void _handlePointerHoverEvent(PointerEvent evt)
{
void _handlePointerHoverEvent(PointerEvent evt) {
foreach (var hitTestEntry in result.path)
{
if (lastMoveTargets.Contains(hitTestEntry.target))
{
foreach (var hitTestEntry in result.path) {
if (this.lastMoveTargets.Contains(hitTestEntry.target)) {
lastMoveTargets.Remove(hitTestEntry.target);
}
else
{
this.lastMoveTargets.Remove(hitTestEntry.target);
} else {
timeStamp:evt.timeStamp,
pointer:evt.pointer,
device:evt.device,
kind:evt.kind
timeStamp: evt.timeStamp,
pointer: evt.pointer,
device: evt.device,
kind: evt.kind
foreach (var lastMoveTarget in lastMoveTargets)
{
foreach (var lastMoveTarget in this.lastMoveTargets) {
timeStamp:evt.timeStamp,
pointer:evt.pointer,
device:evt.device,
kind:evt.kind
timeStamp: evt.timeStamp,
pointer: evt.pointer,
device: evt.device,
kind: evt.kind
lastMoveTargets.Clear();
foreach (var hitTestEntry in result.path)
{
lastMoveTargets.Add(hitTestEntry.target);
this.lastMoveTargets.Clear();
foreach (var hitTestEntry in result.path) {
this.lastMoveTargets.Add(hitTestEntry.target);
}
this.dispatchEvent(evt, result);

foreach (HitTestEntry entry in result.path) {
try {
entry.target.handleEvent(evt, entry);
}
catch (Exception ex) {
} catch (Exception ex) {
Debug.LogError("Error while dispatching a pointer event: " + ex);
}
}

}
}
}
}
}

10
Runtime/gestures/constants.cs


namespace Unity.UIWidgets.gestures {
public static class Constants {
public const double kTouchSlop = 18.0;
public static readonly TimeSpan kLongPressTimeout = new TimeSpan(0, 0, 0, 0, 500);
public const double kMinFlingVelocity = 50.0;

}
}

18
Runtime/gestures/converter.cs


static int _pointerCount = 0;
public void startNewPointer() {
_PointerState._pointerCount += 1;
this._pointer = _PointerState._pointerCount;
_pointerCount += 1;
this._pointer = _pointerCount;
}
public bool down {

public Offset lastPosition;
public override string ToString() {
return string.Format("_PointerState(pointer: {0}, down: {1}, lastPosition: {2})",
this.pointer, this.down, this.lastPosition);
return $"_PointerState(pointer: {this.pointer}, down: {this.down}, lastPosition: {this.lastPosition})";
}
}

break;
}
D.assert(_pointers.ContainsKey(datum.device));
Offset offset = position - state.lastPosition;
state.lastPosition = position;
yield return new PointerMoveEvent(

}
break;
case PointerChange.hover:
{
case PointerChange.hover: {
);
);
break;
}
case PointerChange.up:

}
}
}
}
}

2
Runtime/gestures/drag.cs


void end(DragEndDetails details);
void cancel();
}
}
}

2
Runtime/gestures/drag_details.cs


return this.GetType() + "(" + this.velocity + ")";
}
}
}
}

15
Runtime/gestures/events.cs


}
}
public class PointerHoverEvent : PointerEvent
{
public class PointerHoverEvent : PointerEvent {
public PointerHoverEvent(
TimeSpan timeStamp,
int pointer = 0,

down: false) {
}
}
public class PointerEnterEvent : PointerEvent
{
public class PointerEnterEvent : PointerEvent {
public PointerEnterEvent(
TimeSpan timeStamp,
int pointer = 0,

down: false) {
}
}
public class PointerLeaveEvent : PointerEvent
{
public class PointerLeaveEvent : PointerEvent {
public PointerLeaveEvent(
TimeSpan timeStamp,
int pointer = 0,

down: false) {
}
}
}
}

8
Runtime/gestures/hit_test.cs


}
public override string ToString() {
return string.Format("HitTestResult({0})",
this._path.isEmpty()
? "<empty path>"
: string.Join(", ", this._path.Select(x => x.ToString()).ToArray()));
return
$"HitTestResult({(this._path.isEmpty() ? "<empty path>" : string.Join(", ", this._path.Select(x => x.ToString()).ToArray()))})";
}
}

2
Runtime/gestures/long_press.cs


get { return "long press"; }
}
}
}
}

47
Runtime/gestures/lsq_resolver.cs


this._elements = Enumerable.Repeat(0.0, size).ToList();
}
private _Vector(List<double> values, int offset, int length) {
_Vector(List<double> values, int offset, int length) {
this._offset = offset;
this._length = length;
this._elements = values;

public static double operator *(_Vector a, _Vector b) {
double result = 0.0;
for (int i = 0; i < a._length; i += 1)
for (int i = 0; i < a._length; i += 1) {
}
return result;
}

PolynomialFit result = new PolynomialFit(degree);
// Shorthands for the purpose of notation equivalence to original C++ code.
int m = x.Count;
int m = this.x.Count;
int n = degree + 1;
// Expand the X vector to a matrix A, pre-multiplied by the weights.

for (int i = 1; i < n; i += 1)
for (int i = 1; i < n; i += 1) {
}
}
// Apply the Gram-Schmidt process to A to obtain its QR decomposition.

// Upper triangular matrix, row-major order.
_Matrix r = new _Matrix(n, n);
for (int j = 0; j < n; j += 1) {
for (int h = 0; h < m; h += 1)
for (int h = 0; h < m; h += 1) {
}
for (int h = 0; h < m; h += 1)
for (int h = 0; h < m; h += 1) {
}
}
double norm = q.getRow(j).norm();

}
double inverseNorm = 1.0 / norm;
for (int h = 0; h < m; h += 1)
for (int h = 0; h < m; h += 1) {
for (int i = 0; i < n; i += 1)
}
for (int i = 0; i < n; i += 1) {
}
for (int h = 0; h < m; h += 1)
wy[h] = y[h] * w[h];
for (int h = 0; h < m; h += 1) {
wy[h] = this.y[h] * this.w[h];
}
for (int j = n - 1; j > i; j -= 1)
for (int j = n - 1; j > i; j -= 1) {
}
result.coefficients[i] /= r[i, i];
}

// error), and sumSquaredTotal is the total sum of squares (variance of the
// data) where each has been weighted.
double yMean = 0.0;
for (int h = 0; h < m; h += 1)
yMean += y[h];
for (int h = 0; h < m; h += 1) {
yMean += this.y[h];
}
yMean /= m;
double sumSquaredError = 0.0;

double err = y[h] - result.coefficients[0];
double err = this.y[h] - result.coefficients[0];
term *= x[h];
term *= this.x[h];
sumSquaredError += w[h] * w[h] * err * err;
double v = y[h] - yMean;
sumSquaredTotal += w[h] * w[h] * v * v;
sumSquaredError += this.w[h] * this.w[h] * err * err;
double v = this.y[h] - yMean;
sumSquaredTotal += this.w[h] * this.w[h] * v * v;
}
result.confidence = sumSquaredTotal <= 0.000001 ? 1.0 : 1.0 - (sumSquaredError / sumSquaredTotal);

}
}

10
Runtime/gestures/monodrag.cs


));
return null;
}, debugReport: () =>
string.Format("{0}; fling at {1}.", estimate, velocity));
$"{estimate}; fling at {velocity}.");
} else {
this.invokeCallback<object>("onEnd", () => {
this.onEnd(new DragEndDetails(

}
public class VerticalDragGestureRecognizer : DragGestureRecognizer {
public VerticalDragGestureRecognizer(Object debugOwner = null)
public VerticalDragGestureRecognizer(object debugOwner = null)
: base(debugOwner: debugOwner) {
}

}
public class HorizontalDragGestureRecognizer : DragGestureRecognizer {
public HorizontalDragGestureRecognizer(Object debugOwner = null)
public HorizontalDragGestureRecognizer(object debugOwner = null)
: base(debugOwner: debugOwner) {
}

}
public class PanGestureRecognizer : DragGestureRecognizer {
public PanGestureRecognizer(Object debugOwner = null)
public PanGestureRecognizer(object debugOwner = null)
: base(debugOwner: debugOwner) {
}

get { return "pan"; }
}
}
}
}

4
Runtime/gestures/multitap.cs


public override void rejectGesture(int pointer) {
_TapTracker tracker;
this._trackers.TryGetValue(pointer, out tracker);
if (tracker == null &&
this._firstTap != null &&
this._firstTap.pointer == pointer) {

get { return "double tap"; }
}
}
}
}

5
Runtime/gestures/pointer_router.cs


void _dispatch(PointerEvent evt, PointerRoute route) {
try {
route(evt);
}
catch (Exception ex) {
} catch (Exception ex) {
Debug.LogError("Error while routing a pointer event: " + ex);
}
}

}
}
}
}
}

5
Runtime/gestures/recognizer.cs


});
result = callback();
}
catch (Exception ex) {
} catch (Exception ex) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: ex,
library: "gesture",

properties.add(new EnumProperty<GestureRecognizerState>("state", this.state));
}
}
}
}

12
Runtime/gestures/tap.cs


void _checkDown() {
if (!this._sentTapDown) {
if (this.onTapDown != null)
if (this.onTapDown != null) {
}
this._sentTapDown = true;
}
}

return;
}
if (this.onTapUp != null)
if (this.onTapUp != null) {
}
if (this.onTap != null) {
this.invokeCallback<object>("onTap", () => {
this.onTap();

properties.add(new FlagProperty("wonArenaForPrimaryPointer",
value: this._wonArenaForPrimaryPointer,
ifTrue: "won arena"));
properties.add(new DiagnosticsProperty<Offset>("finalPosition",
properties.add(new DiagnosticsProperty<Offset>("finalPosition",
properties.add(new FlagProperty("sentTapDown",
properties.add(new FlagProperty("sentTapDown",
}
}

2
Runtime/gestures/team.cs


return combiner._add(pointer, member);
}
}
}
}

46
Runtime/gestures/velocity_tracker.cs


}
public bool Equals(Velocity other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return object.Equals(this.pixelsPerSecond, other.pixelsPerSecond);
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.pixelsPerSecond, other.pixelsPerSecond);
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((Velocity) obj);
}

public static bool operator ==(Velocity left, Velocity right) {
return object.Equals(left, right);
return Equals(left, right);
return !object.Equals(left, right);
return !Equals(left, right);
return string.Format("Velocity({0:F1}, {1:F1})", this.pixelsPerSecond.dx, this.pixelsPerSecond.dy);
return $"Velocity({this.pixelsPerSecond.dx:F1}, {this.pixelsPerSecond.dy:F1})";
}
}

public readonly Offset offset;
public override string ToString() {
return string.Format("VelocityEstimate({0:F1}, {1:F1}; offset: {2}, duration: {3}, confidence: {4:F1})",
this.pixelsPerSecond.dx, this.pixelsPerSecond.dy, this.offset, this.duration, this.confidence);
return
$"VelocityEstimate({this.pixelsPerSecond.dx:F1}, {this.pixelsPerSecond.dy:F1}; offset: {this.offset}, duration: {this.duration}, confidence: {this.confidence:F1})";
}
}

public readonly TimeSpan time;
public override string ToString() {
return string.Format("_PointAtTime({0} at {1})", this.point, this.time);
return $"_PointAtTime({this.point} at {this.time})";
}
}

const int _horizonMilliseconds = 100;
const int _minSampleSize = 3;
readonly List<_PointAtTime> _samples = Enumerable.Repeat<_PointAtTime>(null, _historySize).ToList();
readonly List<_PointAtTime> _samples =
Enumerable.Repeat<_PointAtTime>(null, _historySize).ToList();
int _index = 0;
public void addPosition(TimeSpan time, Offset position) {

do {
_PointAtTime sample = this._samples[index];
if (sample == null)
if (sample == null) {
}
if (age > _horizonMilliseconds || delta > _assumePointerMoveStoppedMilliseconds) {
if (age > _horizonMilliseconds ||
delta > _assumePointerMoveStoppedMilliseconds) {
break;
}

return new Velocity(pixelsPerSecond: estimate.pixelsPerSecond);
}
}
}
}

44
Runtime/painting/alignment.cs


}
public bool Equals(Alignment other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((Alignment) obj);
}

}
public static bool operator ==(Alignment a, Alignment b) {
return object.Equals(a, b);
return Equals(a, b);
}
public static bool operator !=(Alignment a, Alignment b) {

public class AlignmentDirectional : IEquatable<AlignmentDirectional> {
public class AlignmentDirectional : IEquatable<AlignmentDirectional> {
public AlignmentDirectional(double start, double y) {
this.start = start;
this.y = y;

public double y;
public static readonly AlignmentDirectional topStart = new AlignmentDirectional(-1.0, -1.0);
public static readonly AlignmentDirectional topCenter = new AlignmentDirectional(0.0, -1.0);
public static readonly AlignmentDirectional topEnd = new AlignmentDirectional(1.0, -1.0);

public static readonly AlignmentDirectional bottomStart = new AlignmentDirectional(-1.0, 1.0);
public static readonly AlignmentDirectional bottomCenter = new AlignmentDirectional(0.0, 1.0);
public static readonly AlignmentDirectional bottomEnd = new AlignmentDirectional(1.0, 1.0);
public AlignmentDirectional add(AlignmentDirectional other) {
return this + other;
}

}
public bool Equals(AlignmentDirectional other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return new Alignment(-start, y);
return new Alignment(-this.start, this.y);
return new Alignment(start, y);
return new Alignment(this.start, this.y);
}
}

2
Runtime/painting/basic_types.cs


paint,
layout,
}
}
}

4
Runtime/painting/binding.cs


namespace Unity.UIWidgets.painting {
public class PaintingBinding : GestureBinding {
public static new PaintingBinding instance {
public new static PaintingBinding instance {
get { return (PaintingBinding) GestureBinding.instance; }
set { GestureBinding.instance = value; }
}

return new ImageCache();
}
}
}
}

60
Runtime/painting/border_radius.cs


namespace Unity.UIWidgets.painting {
public class BorderRadius : IEquatable<BorderRadius> {
private BorderRadius(
BorderRadius(
double topLeft,
double topRight,
double bottomRight,

}
public static BorderRadius all(double radius) {
return BorderRadius.only(radius, radius, radius, radius);
return only(radius, radius, radius, radius);
return BorderRadius.only(top, top, bottom, bottom);
return only(top, top, bottom, bottom);
return BorderRadius.only(left, right, right, left);
return only(left, right, right, left);
}
public static BorderRadius only(

}
public static readonly BorderRadius zero = BorderRadius.all(0);
public static readonly BorderRadius zero = all(0);
public readonly double topLeft;
public readonly double topRight;

bottomRight: this.bottomRight
);
}
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.topLeft.Equals(other.topLeft)
&& this.topRight.Equals(other.topRight)
&& this.bottomRight.Equals(other.bottomRight)

public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((BorderRadius) obj);
}

}
public class BorderWidth : IEquatable<BorderWidth> {
private BorderWidth(
BorderWidth(
double top,
double right,
double bottom,

}
public static BorderWidth all(double width) {
return BorderWidth.only(width, width, width, width);
return only(width, width, width, width);
public static readonly BorderWidth zero = BorderWidth.only();
public static readonly BorderWidth zero = only();
public readonly double top;
public readonly double right;

public bool Equals(BorderWidth other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.top.Equals(other.top)
&& this.right.Equals(other.right)
&& this.bottom.Equals(other.bottom)

public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((BorderWidth) obj);
}

}
}
}
}
}

26
Runtime/painting/borders.cs


}
public bool Equals(BorderSide other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return object.Equals(this.color, other.color) && this.width.Equals(other.width);
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.color, other.color) && this.width.Equals(other.width);
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((BorderSide) obj);
}

}
public static bool operator ==(BorderSide lhs, BorderSide rhs) {
return object.Equals(lhs, rhs);
return Equals(lhs, rhs);
}
public static bool operator !=(BorderSide lhs, BorderSide rhs) {

}
}

46
Runtime/painting/box_border.cs


using System;
using System.Runtime.CompilerServices;
using UnityEditor;
namespace Unity.UIWidgets.painting {
public class Border : IEquatable<Border> {

BorderSide.canMerge(this.right, other.right) &&
BorderSide.canMerge(this.bottom, other.bottom) &&
BorderSide.canMerge(this.left, other.left)) {
return Border.merge(this, other);
return merge(this, other);
}
return null;

path.lineTo(rect.right - this.right.width, rect.top + this.top.width);
path.lineTo(rect.left + this.right.width, rect.top + this.top.width);
}
{
var paint = new Paint {
color = this.right.color,

path.lineTo(rect.right - this.right.width, rect.bottom - this.bottom.width);
path.lineTo(rect.right - this.right.width, rect.top + this.top.width);
}
canvas.drawPath(path, paint);
}

path.lineTo(rect.left + this.left.width, rect.bottom - this.bottom.width);
path.lineTo(rect.right - this.right.width, rect.bottom - this.bottom.width);
}
{
var paint = new Paint {
color = this.left.color,

path.lineTo(rect.left + this.left.width, rect.top + this.top.width);
path.lineTo(rect.left + this.left.width, rect.bottom - this.bottom.width);
}
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return object.Equals(this.top, other.top)
&& object.Equals(this.right, other.right)
&& object.Equals(this.bottom, other.bottom)
&& object.Equals(this.left, other.left);
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.top, other.top)
&& Equals(this.right, other.right)
&& Equals(this.bottom, other.bottom)
&& Equals(this.left, other.left);
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((Border) obj);
}

}
}
}
}
}

52
Runtime/painting/box_decoration.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEditor;
namespace Unity.UIWidgets.painting {
public class BoxDecoration : Decoration, IEquatable<BoxDecoration> {

public override BoxPainter createBoxPainter(VoidCallback onChanged = null) {
return new _BoxDecorationPainter(this, onChanged);
}
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return object.Equals(this.color, other.color)
&& object.Equals(this.image, other.image)
&& object.Equals(this.border, other.border)
&& object.Equals(this.borderRadius, other.borderRadius)
&& object.Equals(this.boxShadow, other.boxShadow)
&& object.Equals(this.gradient, other.gradient);
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.color, other.color)
&& Equals(this.image, other.image)
&& Equals(this.border, other.border)
&& Equals(this.borderRadius, other.borderRadius)
&& Equals(this.boxShadow, other.boxShadow)
&& Equals(this.gradient, other.gradient);
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((BoxDecoration) obj);
}

}
public static bool operator ==(BoxDecoration a, BoxDecoration b) {
return object.Equals(a, b);
return Equals(a, b);
}
public static bool operator !=(BoxDecoration a, BoxDecoration b) {

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.emptyBodyDescription = "<no decorations specified>";
properties.add(new DiagnosticsProperty<Color>("color", color, defaultValue: null));
properties.add(new DiagnosticsProperty<DecorationImage>("image", image, defaultValue: null));
properties.add(new DiagnosticsProperty<Border>("border", border, defaultValue: null));
properties.add(new DiagnosticsProperty<BorderRadius>("borderRadius", borderRadius, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("color", this.color, defaultValue: null));
properties.add(new DiagnosticsProperty<DecorationImage>("image", this.image, defaultValue: null));
properties.add(new DiagnosticsProperty<Border>("border", this.border, defaultValue: null));
properties.add(
new DiagnosticsProperty<BorderRadius>("borderRadius", this.borderRadius, defaultValue: null));
properties.add(new DiagnosticsProperty<Gradient>("gradient", gradient, defaultValue: null));
properties.add(new DiagnosticsProperty<Gradient>("gradient", this.gradient, defaultValue: null));
}
}

public Paint _getBackgroundPaint(Rect rect) {
if (this._cachedBackgroundPaint == null) {
var paint = new Paint();
if (this._decoration.color != null) {
paint.color = this._decoration.color;
}

}
}
}
}
}

23
Runtime/painting/box_fit.cs


using Unity.UIWidgets.ui;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting {
public enum BoxFit {

public static FittedSizes applyBoxFit(BoxFit fit, Size inputSize, Size outputSize) {
if (inputSize.height <= 0.0 || inputSize.width <= 0.0 || outputSize.height <= 0.0 ||
outputSize.width <= 0.0)
outputSize.width <= 0.0) {
}
Size sourceSize = null;
Size destinationSize = null;
switch (fit) {

break;
case BoxFit.contain:
sourceSize = inputSize;
if (outputSize.width / outputSize.height > sourceSize.width / sourceSize.height)
if (outputSize.width / outputSize.height > sourceSize.width / sourceSize.height) {
else
} else {
}
sourceSize = new Size(inputSize.height * outputSize.width / outputSize.height, inputSize.height);
sourceSize = new Size(inputSize.height * outputSize.width / outputSize.height,
inputSize.height);
break;
break;
case BoxFit.fitWidth:
sourceSize = new Size(inputSize.width, inputSize.width * outputSize.height / outputSize.width);
destinationSize = new Size(outputSize.width,

sourceSize = inputSize;
destinationSize = inputSize;
double aspectRatio = inputSize.width / inputSize.height;
if (destinationSize.height > outputSize.height)
if (destinationSize.height > outputSize.height) {
if (destinationSize.width > outputSize.width)
}
if (destinationSize.width > outputSize.width) {
}
break;
}

}
}

30
Runtime/painting/box_shadow.cs


}
public double blurSigma {
get { return BoxShadow.convertRadiusToSigma(this.blurRadius); }
get { return convertRadiusToSigma(this.blurRadius); }
}
public Paint toPaint() {

}
public bool Equals(BoxShadow other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return object.Equals(this.color, other.color)
&& object.Equals(this.offset, other.offset)
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.color, other.color)
&& Equals(this.offset, other.offset)
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((BoxShadow) obj);
}

}
public static bool operator ==(BoxShadow a, BoxShadow b) {
return object.Equals(a, b);
return Equals(a, b);
}
public static bool operator !=(BoxShadow a, BoxShadow b) {

}
}

2
Runtime/painting/clip.cs


clipBehavior, bounds, painter);
}
}
}
}

2
Runtime/painting/decoration.cs


public virtual void dispose() {
}
}
}
}

7
Runtime/painting/decoration_image.cs


using Unity.UIWidgets.ui;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Rect = Unity.UIWidgets.ui.Rect;

}
for (int i = startX; i <= stopX; ++i) {
for (int j = startY; j <= stopY; ++j)
for (int j = startY; j <= stopY; ++j) {
}
}
}

48
Runtime/painting/edge_insets.cs


namespace Unity.UIWidgets.painting {
public class EdgeInsets : IEquatable<EdgeInsets> {
private EdgeInsets(double left, double top, double right, double bottom) {
EdgeInsets(double left, double top, double right, double bottom) {
this.left = left;
this.right = right;
this.top = top;

}
public EdgeInsets flipped {
get { return EdgeInsets.fromLTRB(this.right, this.bottom, this.left, this.top); }
get { return fromLTRB(this.right, this.bottom, this.left, this.top); }
}
public Size inflateSize(Size size) {

);
}
public static readonly EdgeInsets zero = EdgeInsets.only();
public static readonly EdgeInsets zero = only();
public Offset topLeft {
get { return new Offset(this.left, this.top); }

}
public EdgeInsets subtract(EdgeInsets other) {
return EdgeInsets.fromLTRB(
return fromLTRB(
this.left - other.left,
this.top - other.top,
this.right - other.right,

public EdgeInsets add(EdgeInsets other) {
return EdgeInsets.fromLTRB(
return fromLTRB(
this.left + other.left,
this.top + other.top,
this.right + other.right,

public static EdgeInsets operator -(EdgeInsets a, EdgeInsets b) {
return EdgeInsets.fromLTRB(
return fromLTRB(
a.left - b.left,
a.top - b.top,
a.right - b.right,

public static EdgeInsets operator +(EdgeInsets a, EdgeInsets b) {
return EdgeInsets.fromLTRB(
return fromLTRB(
a.left + b.left,
a.top + b.top,
a.right + b.right,

public static EdgeInsets operator -(EdgeInsets a) {
return EdgeInsets.fromLTRB(
return fromLTRB(
-a.left,
-a.top,
-a.right,

public static EdgeInsets operator *(EdgeInsets a, double b) {
return EdgeInsets.fromLTRB(
return fromLTRB(
a.left * b,
a.top * b,
a.right * b,

public static EdgeInsets operator /(EdgeInsets a, double b) {
return EdgeInsets.fromLTRB(
return fromLTRB(
a.left / b,
a.top / b,
a.right / b,

public static EdgeInsets operator %(EdgeInsets a, double b) {
return EdgeInsets.fromLTRB(
return fromLTRB(
a.left % b,
a.top % b,
a.right % b,

double? right = null,
double? bottom = null
) {
return EdgeInsets.only(
return only(
left: left ?? this.left,
top: top ?? this.top,
right: right ?? this.right,

public bool Equals(EdgeInsets other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.left.Equals(other.left)
&& this.right.Equals(other.right)
&& this.top.Equals(other.top)

public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((EdgeInsets) obj);
}

}
public static bool operator ==(EdgeInsets a, EdgeInsets b) {
return object.Equals(a, b);
return Equals(a, b);
}
public static bool operator !=(EdgeInsets a, EdgeInsets b) {

}
}

2
Runtime/painting/gradient.cs


namespace Unity.UIWidgets.painting {
public abstract class Gradient {
}
}
}

16
Runtime/painting/image_cache.cs


int _maximumSize = _kDefaultSize;
public int maximumSize {
get => this._maximumSize;
get { return this._maximumSize; }
set {
D.assert(value >= 0);
if (value == this._maximumSize) {

}
}
public int currentSize => this._cache.Count;
public int currentSize {
get { return this._cache.Count; }
}
int _maximumSizeBytes = _kDefaultSizeBytes;

int _currentSizeBytes;
public int currentSizeBytes => this._currentSizeBytes;
public int currentSizeBytes {
get { return this._currentSizeBytes; }
}
public void clear() {
this._cache.Clear();

ImageListener listener = null;
listener = (info, syncCall) => {
result.removeListener(listener);
int imageSize = info?.image == null ? 0 : info.image.width & info.image.height * 4;
int imageSize = info?.image == null ? 0 : info.image.width & (info.image.height * 4);
_CachedImage cachedImage = new _CachedImage {
completer = result,
sizeBytes = imageSize,

public int sizeBytes;
public LinkedListNode<object> node;
}
}
}

142
Runtime/painting/image_provider.cs


using System.Collections.Generic;
using RSG;
using System.Collections.Generic;
using RSG;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;

public static readonly ImageConfiguration empty = new ImageConfiguration();
public bool Equals(ImageConfiguration other) {
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.bundle, other.bundle) && this.devicePixelRatio.Equals(other.devicePixelRatio) &&
Equals(this.locale, other.locale) && Equals(this.size, other.size) &&
this.platform == other.platform;

if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ImageConfiguration) obj);
}

}
public class AssetBundleImageKey : IEquatable<AssetBundleImageKey> {
public AssetBundleImageKey(
AssetBundle bundle,
string name,

public readonly double scale;
public bool Equals(AssetBundleImageKey other) {
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((AssetBundleImageKey) obj);
}

}
public bool Equals(NetworkImage other) {
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((NetworkImage) obj);
}

protected override ImageStreamCompleter load(FileImage key) {
return new MultiFrameImageStreamCompleter(this._loadAsync(key),
scale: key.scale,
informationCollector: information => {
information.AppendLine($"Path: {this.file}");
});
informationCollector: information => { information.AppendLine($"Path: {this.file}"); });
}
IPromise<Codec> _loadAsync(FileImage key) {

var data = www.downloadHandler.data;
yield return data;
}
using (var www = UnityWebRequestTexture.GetTexture(uri)) {
yield return www.SendWebRequest();

}
public bool Equals(FileImage other) {
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((FileImage) obj);
}

}
public class MemoryImage : ImageProvider<MemoryImage>, IEquatable<MemoryImage> {
protected override IPromise<MemoryImage> obtainKey(ImageConfiguration configuration) {
return Promise<MemoryImage>.Resolved(this);
}

this._loadAsync(key),
scale: key.scale);
}
IPromise<Codec> _loadAsync(MemoryImage key) {
D.assert(key == this);

public bool Equals(MemoryImage other) {
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((MemoryImage) obj);
}

}
public bool Equals(ExactAssetImage other) {
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ExactAssetImage) obj);
}

return $"{this.GetType()}(name: \"{this.assetName}\", scale: {this.scale}, bundle: {this.bundle})";
}
}
}
}

34
Runtime/painting/image_resolution.cs


protected override
IPromise<AssetBundleImageKey> obtainKey(ImageConfiguration configuration) {
AssetBundle chosenBundle = this.bundle ? this.bundle : configuration.bundle;
var devicePixelRatio = configuration.devicePixelRatio ?? Window.instance.devicePixelRatio;
var coroutine = Window.instance.startCoroutine(this._loadAssetAsync(chosenBundle, devicePixelRatio));

asset = request.asset;
}
if (asset != null) {
if (asset != null) {
yield return new AssetBundleImageKey(
bundle,
assetName,

}
}
yield return new AssetBundleImageKey(
bundle,
this.assetName,

public bool Equals(AssetImage other) {
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return ((this.assetName != null ? this.assetName.GetHashCode() : 0) * 397) ^ (this.bundle != null ? this.bundle.GetHashCode() : 0);
return ((this.assetName != null ? this.assetName.GetHashCode() : 0) * 397) ^
(this.bundle != null ? this.bundle.GetHashCode() : 0);
}
}

return $"{this.GetType()}(bundle: {this.bundle}, name: \"{this.assetName}\")";
}
}
}
}

58
Runtime/painting/image_stream.cs


using RSG;
using Unity.UIWidgets.ui;
using UnityEngine;
using RSG;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting {
public class ImageInfo : IEquatable<ImageInfo> {

public readonly double scale;
public bool Equals(ImageInfo other) {
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ImageInfo) obj);
}

public delegate void ImageErrorListener(Exception exception);
internal class _ImageListenerPair {
class _ImageListenerPair {
public ImageListener listener;
public ImageErrorListener errorListener;
}

}
ImageStreamCompleter _completer;
public ImageStreamCompleter completer => this._completer;
public ImageStreamCompleter completer {
get { return this._completer; }
}
List<_ImageListenerPair> _listeners;

}
}
public object key => this._completer != null ? (object) this._completer : this;
public object key {
get { return this._completer != null ? (object) this._completer : this; }
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);

if (this.currentImage != null) {
try {
listener(this.currentImage, true);
}
catch (Exception ex) {
} catch (Exception ex) {
this.reportError(
context: "by a synchronously-called image listener",
exception: ex

if (this.currentError != null && onError != null) {
try {
onError(this.currentError.exception);
}
catch (Exception ex) {
} catch (Exception ex) {
UIWidgetsError.reportError(
new UIWidgetsErrorDetails(
exception: ex,

foreach (var listener in localListeners) {
try {
listener(image, false);
}
catch (Exception ex) {
} catch (Exception ex) {
this.reportError(
context: "by an image listener",
exception: ex

foreach (var errorListener in localErrorListeners) {
try {
errorListener(exception);
}
catch (Exception ex) {
} catch (Exception ex) {
UIWidgetsError.reportError(
new UIWidgetsErrorDetails(
context: "by an image error listener",

InformationCollector informationCollector = null) {
D.assert(image != null);
image.Then(result => {
this.setImage(result);
}).Catch(err => {
image.Then(result => { this.setImage(result); }).Catch(err => {
this.reportError(
context: "resolving a single-frame image stream",
exception: err,

this._framesEmitted += 1;
}
bool _hasActiveListeners => this._listeners.isNotEmpty();
bool _hasActiveListeners {
get { return this._listeners.isNotEmpty(); }
}
public override void addListener(ImageListener listener, ImageErrorListener onError = null) {
if (!this._hasActiveListeners && this._codec != null) {

}
}
}
}
}

12
Runtime/painting/matrix_utils.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
using Unity.UIWidgets.ui;
public static Offset getAsTranslation(this Matrix3 matrix3)
{
public static Offset getAsTranslation(this Matrix3 matrix3) {
}
}

537
Runtime/painting/text_painter.cs


using Canvas = Unity.UIWidgets.ui.Canvas;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.painting
{
public class TextPainter
{
private TextSpan _text;
private TextAlign _textAlign;
private TextDirection? _textDirection;
private double _textScaleFactor;
private Paragraph _layoutTemplate;
private Paragraph _paragraph;
private bool _needsLayout = true;
private int _maxLines;
private string _ellipsis;
private double _lastMinWidth;
private double _lastMaxWidth;
namespace Unity.UIWidgets.painting {
public class TextPainter {
TextSpan _text;
TextAlign _textAlign;
TextDirection? _textDirection;
double _textScaleFactor;
Paragraph _layoutTemplate;
Paragraph _paragraph;
bool _needsLayout = true;
int _maxLines;
string _ellipsis;
double _lastMinWidth;
double _lastMaxWidth;
public TextPainter(TextSpan text,
TextAlign textAlign = TextAlign.left,

string ellipsis = "")
{
_text = text;
_textAlign = textAlign;
_textDirection = textDirection;
_textScaleFactor = textScaleFactor;
_maxLines = maxLines;
_ellipsis = ellipsis;
string ellipsis = "") {
this._text = text;
this._textAlign = textAlign;
this._textDirection = textDirection;
this._textScaleFactor = textScaleFactor;
this._maxLines = maxLines;
this._ellipsis = ellipsis;
public double textScaleFactor
{
get { return _textScaleFactor; }
set
{
if (_textScaleFactor == value)
public double textScaleFactor {
get { return this._textScaleFactor; }
set {
if (this._textScaleFactor == value) {
_textScaleFactor = value;
_paragraph = null;
_layoutTemplate = null;
_needsLayout = true;
}
this._textScaleFactor = value;
this._paragraph = null;
this._layoutTemplate = null;
this._needsLayout = true;
public string ellipsis
{
get { return _ellipsis; }
set
{
if (_ellipsis == value)
{
public string ellipsis {
get { return this._ellipsis; }
set {
if (this._ellipsis == value) {
_ellipsis = value;
_paragraph = null;
_needsLayout = true;
this._ellipsis = value;
this._paragraph = null;
this._needsLayout = true;
public TextSpan text
{
get { return _text; }
set
{
if (text.Equals(value))
{
public TextSpan text {
get { return this._text; }
set {
if (this.text.Equals(value)) {
if (!Equals(_text == null ? null : _text.style, value == null ? null : value.style))
{
_layoutTemplate = null;
if (!Equals(this._text == null ? null : this._text.style, value == null ? null : value.style)) {
this._layoutTemplate = null;
_text = value;
_paragraph = null;
_needsLayout = true;
this._text = value;
this._paragraph = null;
this._needsLayout = true;
public Size size
{
get
{
Debug.Assert(!_needsLayout);
return new Size(width, height);
public Size size {
get {
Debug.Assert(!this._needsLayout);
return new Size(this.width, this.height);
public TextDirection? textDirection
{
get { return _textDirection; }
set
{
if (textDirection == value)
{
public TextDirection? textDirection {
get { return this._textDirection; }
set {
if (this.textDirection == value) {
_textDirection = value;
_paragraph = null;
_layoutTemplate = null;
_needsLayout = true;
this._textDirection = value;
this._paragraph = null;
this._layoutTemplate = null;
this._needsLayout = true;
public TextAlign textAlign
{
get { return _textAlign; }
set
{
if (_textAlign == value)
{
public TextAlign textAlign {
get { return this._textAlign; }
set {
if (this._textAlign == value) {
_textAlign = value;
_paragraph = null;
_needsLayout = true;
this._textAlign = value;
this._paragraph = null;
this._needsLayout = true;
public bool didExceedMaxLines
{
get
{
Debug.Assert(!_needsLayout);
return _paragraph.didExceedMaxLines;
public bool didExceedMaxLines {
get {
Debug.Assert(!this._needsLayout);
return this._paragraph.didExceedMaxLines;
public int maxLines
{
get { return _maxLines; }
set
{
if (_maxLines == value)
{
public int maxLines {
get { return this._maxLines; }
set {
if (this._maxLines == value) {
_maxLines = value;
_paragraph = null;
_needsLayout = true;
this._maxLines = value;
this._paragraph = null;
this._needsLayout = true;
public double minIntrinsicWidth
{
get
{
Debug.Assert(!_needsLayout);
return _applyFloatingPointHack(_paragraph.minIntrinsicWidth);
public double minIntrinsicWidth {
get {
Debug.Assert(!this._needsLayout);
return this._applyFloatingPointHack(this._paragraph.minIntrinsicWidth);
public double maxIntrinsicWidth
{
get
{
Debug.Assert(!_needsLayout);
return _applyFloatingPointHack(_paragraph.maxIntrinsicWidth);
public double maxIntrinsicWidth {
get {
Debug.Assert(!this._needsLayout);
return this._applyFloatingPointHack(this._paragraph.maxIntrinsicWidth);
public double height
{
get
{
Debug.Assert(!_needsLayout);
return _applyFloatingPointHack(_paragraph.height);
public double height {
get {
Debug.Assert(!this._needsLayout);
return this._applyFloatingPointHack(this._paragraph.height);
public double width
{
get
{
Debug.Assert(!_needsLayout);
return _applyFloatingPointHack(_paragraph.width);
public double width {
get {
Debug.Assert(!this._needsLayout);
return this._applyFloatingPointHack(this._paragraph.width);
public double computeDistanceToActualBaseline(TextBaseline baseline)
{
Debug.Assert(!_needsLayout);
switch (baseline)
{
case TextBaseline.alphabetic:
return _paragraph.alphabeticBaseline;
case TextBaseline.ideographic:
return _paragraph.ideographicBaseline;
public double computeDistanceToActualBaseline(TextBaseline baseline) {
Debug.Assert(!this._needsLayout);
switch (baseline) {
case TextBaseline.alphabetic:
return this._paragraph.alphabeticBaseline;
case TextBaseline.ideographic:
return this._paragraph.ideographicBaseline;
public void layout(double minWidth = 0.0, double maxWidth = double.PositiveInfinity)
{
Debug.Assert(text != null, "TextPainter.text must be set to a non-null value before using the TextPainter.");
Debug.Assert(textDirection != null, "TextPainter.textDirection must be set to a non-null value before using the TextPainter.");
if (!_needsLayout && minWidth == _lastMinWidth && maxWidth == _lastMaxWidth)
{
public void layout(double minWidth = 0.0, double maxWidth = double.PositiveInfinity) {
Debug.Assert(this.text != null,
"TextPainter.text must be set to a non-null value before using the TextPainter.");
Debug.Assert(this.textDirection != null,
"TextPainter.textDirection must be set to a non-null value before using the TextPainter.");
if (!this._needsLayout && minWidth == this._lastMinWidth && maxWidth == this._lastMaxWidth) {
_needsLayout = false;
if (_paragraph == null)
{
var builder = new ParagraphBuilder(_createParagraphStyle());
_text.build(builder, textScaleFactor);
_paragraph = builder.build();
this._needsLayout = false;
if (this._paragraph == null) {
var builder = new ParagraphBuilder(this._createParagraphStyle());
this._text.build(builder, this.textScaleFactor);
this._paragraph = builder.build();
_lastMinWidth = minWidth;
_lastMaxWidth = maxWidth;
_paragraph.layout(new ParagraphConstraints(maxWidth));
if (minWidth != maxWidth)
{
var newWidth = MathUtils.clamp(maxIntrinsicWidth, minWidth, maxWidth);
if (newWidth != width)
{
_paragraph.layout(new ParagraphConstraints(newWidth));
this._lastMinWidth = minWidth;
this._lastMaxWidth = maxWidth;
this._paragraph.layout(new ParagraphConstraints(maxWidth));
if (minWidth != maxWidth) {
var newWidth = MathUtils.clamp(this.maxIntrinsicWidth, minWidth, maxWidth);
if (newWidth != this.width) {
this._paragraph.layout(new ParagraphConstraints(newWidth));
public void paint(Canvas canvas, Offset offset)
{
Debug.Assert(!_needsLayout);
_paragraph.paint(canvas, offset);
public void paint(Canvas canvas, Offset offset) {
Debug.Assert(!this._needsLayout);
this._paragraph.paint(canvas, offset);
public Offset getOffsetForCaret(TextPosition position, Rect caretPrototype)
{
D.assert(!_needsLayout);
public Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) {
D.assert(!this._needsLayout);
if (offset > 0)
{
var prevCodeUnit = _text.codeUnitAt(offset);
if (offset > 0) {
var prevCodeUnit = this._text.codeUnitAt(offset);
var rectNextLine = _paragraph.getNextLineStartRect();
if (rectNextLine != null)
{
var rectNextLine = this._paragraph.getNextLineStartRect();
if (rectNextLine != null) {
switch (position.affinity)
{
case TextAffinity.upstream:
return _getOffsetFromUpstream(offset, caretPrototype) ??
_getOffsetFromDownstream(offset, caretPrototype) ?? _emptyOffset;
case TextAffinity.downstream:
return _getOffsetFromDownstream(offset, caretPrototype) ??
_getOffsetFromUpstream(offset, caretPrototype) ?? _emptyOffset;
switch (position.affinity) {
case TextAffinity.upstream:
return this._getOffsetFromUpstream(offset, caretPrototype) ??
this._getOffsetFromDownstream(offset, caretPrototype) ?? this._emptyOffset;
case TextAffinity.downstream:
return this._getOffsetFromDownstream(offset, caretPrototype) ??
this._getOffsetFromUpstream(offset, caretPrototype) ?? this._emptyOffset;
public Paragraph.LineRange getLineRange(int lineNumber)
{
D.assert(!_needsLayout);
return _paragraph.getLineRange(lineNumber);
public Paragraph.LineRange getLineRange(int lineNumber) {
D.assert(!this._needsLayout);
return this._paragraph.getLineRange(lineNumber);
public Paragraph.LineRange getLineRange(TextPosition textPosition)
{
return getLineRange(getLineIndex(textPosition));
public Paragraph.LineRange getLineRange(TextPosition textPosition) {
return this.getLineRange(this.getLineIndex(textPosition));
public List<TextBox> getBoxesForSelection(TextSelection selection)
{
D.assert(!_needsLayout);
var results = _paragraph.getRectsForRange(selection.start, selection.end);
public List<TextBox> getBoxesForSelection(TextSelection selection) {
D.assert(!this._needsLayout);
var results = this._paragraph.getRectsForRange(selection.start, selection.end);
D.assert(!_needsLayout);
var result = _paragraph.getGlyphPositionAtCoordinate(offset.dx, offset.dy);
D.assert(!this._needsLayout);
var result = this._paragraph.getGlyphPositionAtCoordinate(offset.dx, offset.dy);
public TextRange getWordBoundary(TextPosition position)
{
D.assert(!_needsLayout);
var range = _paragraph.getWordBoundary(position.offset);
public TextRange getWordBoundary(TextPosition position) {
D.assert(!this._needsLayout);
var range = this._paragraph.getWordBoundary(position.offset);
public TextPosition getPositionVerticalMove(TextPosition position, int move)
{
D.assert(!_needsLayout);
var offset = getOffsetForCaret(position, Rect.zero);
var lineIndex = Math.Min(Math.Max(_paragraph.getLine(position) + move, 0), _paragraph.getLineCount() - 1);
var targetLineStart = _paragraph.getLineRange(lineIndex).start;
var newLineOffset = getOffsetForCaret(new TextPosition(targetLineStart), Rect.zero);
return getPositionForOffset(new Offset(offset.dx, newLineOffset.dy));
public TextPosition getPositionVerticalMove(TextPosition position, int move) {
D.assert(!this._needsLayout);
var offset = this.getOffsetForCaret(position, Rect.zero);
var lineIndex = Math.Min(Math.Max(this._paragraph.getLine(position) + move, 0),
this._paragraph.getLineCount() - 1);
var targetLineStart = this._paragraph.getLineRange(lineIndex).start;
var newLineOffset = this.getOffsetForCaret(new TextPosition(targetLineStart), Rect.zero);
return this.getPositionForOffset(new Offset(offset.dx, newLineOffset.dy));
public int getLineIndex(TextPosition position)
{
D.assert(!_needsLayout);
return _paragraph.getLine(position);
public int getLineIndex(TextPosition position) {
D.assert(!this._needsLayout);
return this._paragraph.getLine(position);
public int getLineCount()
{
D.assert(!_needsLayout);
return _paragraph.getLineCount();
public int getLineCount() {
D.assert(!this._needsLayout);
return this._paragraph.getLineCount();
public TextPosition getWordRight(TextPosition position)
{
D.assert(!_needsLayout);
public TextPosition getWordRight(TextPosition position) {
D.assert(!this._needsLayout);
while(true)
{
var range = _paragraph.getWordBoundary(offset);
if (range.end == range.start)
{
while (true) {
var range = this._paragraph.getWordBoundary(offset);
if (range.end == range.start) {
if (!char.IsWhiteSpace((char)(text.codeUnitAt(range.start)??0)))
{
if (!char.IsWhiteSpace((char) (this.text.codeUnitAt(range.start) ?? 0))) {
public TextPosition getWordLeft(TextPosition position)
{
D.assert(!_needsLayout);
public TextPosition getWordLeft(TextPosition position) {
D.assert(!this._needsLayout);
while(true)
{
var range = _paragraph.getWordBoundary(offset);
if (!char.IsWhiteSpace((char)(text.codeUnitAt(range.start)??0)))
{
while (true) {
var range = this._paragraph.getWordBoundary(offset);
if (!char.IsWhiteSpace((char) (this.text.codeUnitAt(range.start) ?? 0))) {
if (offset == 0)
{
if (offset == 0) {
private ParagraphStyle _createParagraphStyle(TextDirection defaultTextDirection = TextDirection.ltr)
{
if (_text.style == null)
{
ParagraphStyle _createParagraphStyle(TextDirection defaultTextDirection = TextDirection.ltr) {
if (this._text.style == null) {
textAlign: textAlign,
textDirection: textDirection ?? defaultTextDirection,
maxLines: maxLines,
ellipsis: ellipsis
textAlign: this.textAlign,
textDirection: this.textDirection ?? defaultTextDirection,
maxLines: this.maxLines,
ellipsis: this.ellipsis
return _text.style.getParagraphStyle(textAlign, textDirection ?? defaultTextDirection,
ellipsis, maxLines, textScaleFactor);
return this._text.style.getParagraphStyle(this.textAlign, this.textDirection ?? defaultTextDirection,
this.ellipsis, this.maxLines, this.textScaleFactor);
public double preferredLineHeight
{
get
{
if (_layoutTemplate == null)
{
var builder = new ParagraphBuilder(
_createParagraphStyle(TextDirection.ltr)
public double preferredLineHeight {
get {
if (this._layoutTemplate == null) {
var builder = new ParagraphBuilder(this._createParagraphStyle(TextDirection.ltr)
if (text != null && text.style != null)
{
builder.pushStyle(text.style);
if (this.text != null && this.text.style != null) {
builder.pushStyle(this.text.style);
_layoutTemplate = builder.build();
_layoutTemplate.layout(new ParagraphConstraints(double.PositiveInfinity));
this._layoutTemplate = builder.build();
this._layoutTemplate.layout(new ParagraphConstraints(double.PositiveInfinity));
return _layoutTemplate.height;
return this._layoutTemplate.height;
private double _applyFloatingPointHack(double layoutValue)
{
double _applyFloatingPointHack(double layoutValue) {
private Offset _getOffsetFromUpstream(int offset, Rect caretPrototype) {
var prevCodeUnit = _text.codeUnitAt(offset - 1);
if (prevCodeUnit == null)
Offset _getOffsetFromUpstream(int offset, Rect caretPrototype) {
var prevCodeUnit = this._text.codeUnitAt(offset - 1);
if (prevCodeUnit == null) {
var prevRuneOffset = _isUtf16Surrogate((int)prevCodeUnit) ? offset - 2 : offset - 1;
var boxes = _paragraph.getRectsForRange(prevRuneOffset, offset);
if (boxes.Count == 0)
}
var prevRuneOffset = _isUtf16Surrogate((int) prevCodeUnit) ? offset - 2 : offset - 1;
var boxes = this._paragraph.getRectsForRange(prevRuneOffset, offset);
if (boxes.Count == 0) {
}
var box = boxes[0];
var caretEnd = box.end;
var dx = box.direction == TextDirection.rtl ? caretEnd : caretEnd - caretPrototype.width;

private Offset _getOffsetFromDownstream(int offset, Rect caretPrototype) {
var nextCodeUnit = _text.codeUnitAt(offset);
if (nextCodeUnit == null)
Offset _getOffsetFromDownstream(int offset, Rect caretPrototype) {
var nextCodeUnit = this._text.codeUnitAt(offset);
if (nextCodeUnit == null) {
var nextRuneOffset = _isUtf16Surrogate((int)nextCodeUnit) ? offset + 2 : offset + 1;
var boxes = _paragraph.getRectsForRange(offset, nextRuneOffset);
if (boxes.Count == 0)
}
var nextRuneOffset = _isUtf16Surrogate((int) nextCodeUnit) ? offset + 2 : offset + 1;
var boxes = this._paragraph.getRectsForRange(offset, nextRuneOffset);
if (boxes.Count == 0) {
}
var box = boxes[0];
var caretStart = box.start;
var dx = box.direction == TextDirection.rtl ? caretStart - caretPrototype.width : caretStart;

private Offset _emptyOffset
{
get
{
D.assert(!_needsLayout);
switch (textAlign)
{
case TextAlign.left:
return Offset.zero;
case TextAlign.right:
return new Offset(width, 0.0);
case TextAlign.center:
return new Offset(width / 2.0, 0.0);
case TextAlign.justify:
if (textDirection == TextDirection.rtl)
{
return new Offset(width, 0.0);
}
return Offset.zero;
Offset _emptyOffset {
get {
D.assert(!this._needsLayout);
switch (this.textAlign) {
case TextAlign.left:
return Offset.zero;
case TextAlign.right:
return new Offset(this.width, 0.0);
case TextAlign.center:
return new Offset(this.width / 2.0, 0.0);
case TextAlign.justify:
if (this.textDirection == TextDirection.rtl) {
return new Offset(this.width, 0.0);
}
return Offset.zero;
private static bool _isUtf16Surrogate(int value)
{
static bool _isUtf16Surrogate(int value) {
}
}

237
Runtime/painting/text_span.cs


using Unity.UIWidgets.ui;
using UnityEngine.Assertions;
namespace Unity.UIWidgets.painting
{
public class GestureMock
{
}
public class TextSpan: DiagnosticableTree, IEquatable<TextSpan>
{
namespace Unity.UIWidgets.painting {
public class TextSpan : DiagnosticableTree, IEquatable<TextSpan> {
public TextSpan(string text = "", TextStyle style = null, List<TextSpan> children = null)
{
public TextSpan(string text = "", TextStyle style = null, List<TextSpan> children = null) {
public void build(ParagraphBuilder builder, double textScaleFactor = 1.0)
{
var hasTyle = style != null;
if (hasTyle)
{
builder.pushStyle(style);
public void build(ParagraphBuilder builder, double textScaleFactor = 1.0) {
var hasTyle = this.style != null;
if (hasTyle) {
builder.pushStyle(this.style);
if (!string.IsNullOrEmpty(text))
{
builder.addText(text);
if (!string.IsNullOrEmpty(this.text)) {
builder.addText(this.text);
if (children != null)
{
foreach (var child in children)
{
if (this.children != null) {
foreach (var child in this.children) {
if (hasTyle)
{
if (hasTyle) {
bool visitTextSpan(Visitor visitor)
{
if (!string.IsNullOrEmpty(text))
{
if (!visitor.Invoke(this))
{
bool visitTextSpan(Visitor visitor) {
if (!string.IsNullOrEmpty(this.text)) {
if (!visitor.Invoke(this)) {
if (children != null)
{
foreach (var child in children)
{
if (!child.visitTextSpan(visitor))
{
if (this.children != null) {
foreach (var child in this.children) {
if (!child.visitTextSpan(visitor)) {
TextSpan getSpanForPosition(TextPosition position)
{
TextSpan getSpanForPosition(TextPosition position) {
visitTextSpan((span) =>
{
this.visitTextSpan((span) => {
(targetOffset == endOffset && affinity == TextAffinity.upstream))
{
(targetOffset == endOffset && affinity == TextAffinity.upstream)) {
result = span;
return false;
}

return result;
}
public string toPlainText()
{
public string toPlainText() {
visitTextSpan((span) =>
{
this.visitTextSpan((span) => {
sb.Append(span.text);
return true;
});

public int? codeUnitAt(int index)
{
if (index < 0)
{
public int? codeUnitAt(int index) {
if (index < 0) {
visitTextSpan(span =>
{
if (index - offset < span.text.Length)
{
this.visitTextSpan(span => {
if (index - offset < span.text.Length) {
result = span.text[index - offset];
return false;
}

return result;
}
public RenderComparison compareTo(TextSpan other)
{
if (Equals(other))
{
public RenderComparison compareTo(TextSpan other) {
if (this.Equals(other)) {
if (other.text != text
|| ((children == null) != (other.children == null))
|| (children != null && other.children != null && children.Count != other.children.Count)
|| ((style == null) != (other.style != null))
)
{
if (other.text != this.text
|| ((this.children == null) != (other.children == null))
|| (this.children != null && other.children != null && this.children.Count != other.children.Count)
|| ((this.style == null) != (other.style != null))
) {
RenderComparison result = Equals(recognizer, other.recognizer)
RenderComparison result = Equals(this.recognizer, other.recognizer)
if (style != null)
{
var candidate = style.compareTo(other.style);
if (candidate > result)
{
if (this.style != null) {
var candidate = this.style.compareTo(other.style);
if (candidate > result) {
if (result == RenderComparison.layout)
{
if (result == RenderComparison.layout) {
if (children != null)
{
for (var index = 0; index < children.Count; index++)
{
var candidate = children[index].compareTo(other.children[index]);
if (candidate > result)
{
if (this.children != null) {
for (var index = 0; index < this.children.Count; index++) {
var candidate = this.children[index].compareTo(other.children[index]);
if (candidate > result) {
if (result == RenderComparison.layout)
{
if (result == RenderComparison.layout) {
return result;
}
}

}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((TextSpan) obj);
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((TextSpan) obj);
public override int GetHashCode()
{
unchecked
{
var hashCode = (style != null ? style.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (text != null ? text.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (childHash());
public override int GetHashCode() {
unchecked {
var hashCode = (this.style != null ? this.style.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.text != null ? this.text.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.childHash());
public bool Equals(TextSpan other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Equals(style, other.style) && string.Equals(text, other.text) && childEquals(children, other.children);
public bool Equals(TextSpan other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.style, other.style) && string.Equals(this.text, other.text) &&
childEquals(this.children, other.children);
public static bool operator ==(TextSpan left, TextSpan right)
{
public static bool operator ==(TextSpan left, TextSpan right) {
public static bool operator !=(TextSpan left, TextSpan right)
{
public static bool operator !=(TextSpan left, TextSpan right) {
private int childHash()
{
unchecked
{
int childHash() {
unchecked {
if (children != null)
{
foreach (var child in children)
{
if (this.children != null) {
foreach (var child in this.children) {
hashCode = (hashCode * 397) ^ (child != null ? child.GetHashCode() : 0);
}
}

}
private static bool childEquals(List<TextSpan> left, List<TextSpan> right)
{
if (ReferenceEquals(left, right))
{
static bool childEquals(List<TextSpan> left, List<TextSpan> right) {
if (ReferenceEquals(left, right)) {
if (left == null || right == null)
{
if (left == null || right == null) {
if (style != null)
{
style.debugFillProperties(properties);
}
if (this.style != null) {
this.style.debugFillProperties(properties);
}
"recognizer", recognizer,
description: recognizer == null ? "" : recognizer.GetType().FullName,
"recognizer", this.recognizer,
description: this.recognizer == null ? "" : this.recognizer.GetType().FullName,
properties.add(new StringProperty("text", text, showName: false, defaultValue: Diagnostics.kNullDefaultValue));
if (style == null && text == null && children == null)
{
properties.add(DiagnosticsNode.message("(empty)"));
properties.add(new StringProperty("text", this.text, showName: false,
defaultValue: Diagnostics.kNullDefaultValue));
if (this.style == null && this.text == null && this.children == null) {
properties.add(DiagnosticsNode.message("(empty)"));
if (children == null)
{
if (this.children == null) {
return children.Select((child) =>
{
if (child != null)
{
return this.children.Select((child) => {
if (child != null) {
}
else
{
} else {
return DiagnosticsNode.message("<null child>");
}
}).ToList();

298
Runtime/painting/text_style.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting
{
public class TextStyle : Diagnosticable, IEquatable<TextStyle>, ParagraphBuilder.ITextStyleProvider
{
namespace Unity.UIWidgets.painting {
public class TextStyle : Diagnosticable, IEquatable<TextStyle>, ParagraphBuilder.ITextStyleProvider {
public static readonly double _defaultFontSize = 14.0;
public readonly bool inherit;
public readonly Color color;

TextBaseline? textBaseline = null, double? height = null, Paint background = null,
TextDecoration decoration = null,
Color decorationColor = null, TextDecorationStyle? decorationStyle = null,
string fontFamily = null, string debugLabel = null)
{
string fontFamily = null, string debugLabel = null) {
this.inherit = inherit;
this.color = color;
this.fontSize = fontSize;

this.background = background;
}
public ui.TextStyle getTextStyle(ui.TextStyle currentStyle = null)
{
if (currentStyle != null)
{
public ui.TextStyle getTextStyle(ui.TextStyle currentStyle = null) {
if (currentStyle != null) {
color: color??currentStyle.color,
fontSize: fontSize??currentStyle.fontSize,
fontWeight: fontWeight??currentStyle.fontWeight,
fontStyle: fontStyle??currentStyle.fontStyle,
letterSpacing: letterSpacing??currentStyle.letterSpacing,
wordSpacing: wordSpacing??currentStyle.wordSpacing,
textBaseline: textBaseline??currentStyle.textBaseline,
height: height??currentStyle.height,
decoration: decoration??currentStyle.decoration,
decorationColor: decorationColor??currentStyle.decorationColor,
fontFamily: fontFamily??currentStyle.fontFamily,
background: background??currentStyle.background
color: this.color ?? currentStyle.color,
fontSize: this.fontSize ?? currentStyle.fontSize,
fontWeight: this.fontWeight ?? currentStyle.fontWeight,
fontStyle: this.fontStyle ?? currentStyle.fontStyle,
letterSpacing: this.letterSpacing ?? currentStyle.letterSpacing,
wordSpacing: this.wordSpacing ?? currentStyle.wordSpacing,
textBaseline: this.textBaseline ?? currentStyle.textBaseline,
height: this.height ?? currentStyle.height,
decoration: this.decoration ?? currentStyle.decoration,
decorationColor: this.decorationColor ?? currentStyle.decorationColor,
fontFamily: this.fontFamily ?? currentStyle.fontFamily,
background: this.background ?? currentStyle.background
color: color,
fontSize: fontSize,
fontWeight: fontWeight,
fontStyle: fontStyle,
letterSpacing: letterSpacing,
wordSpacing: wordSpacing,
textBaseline: textBaseline,
height: height,
decoration: decoration,
decorationColor: decorationColor,
fontFamily: fontFamily,
background: background
color: this.color,
fontSize: this.fontSize,
fontWeight: this.fontWeight,
fontStyle: this.fontStyle,
letterSpacing: this.letterSpacing,
wordSpacing: this.wordSpacing,
textBaseline: this.textBaseline,
height: this.height,
decoration: this.decoration,
decorationColor: this.decorationColor,
fontFamily: this.fontFamily,
background: this.background
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)
{
public RenderComparison compareTo(TextStyle other) {
if (this.inherit != other.inherit || this.fontFamily != other.fontFamily
|| this.fontSize != other.fontSize || this.fontWeight != other.fontWeight
|| this.fontStyle != other.fontStyle ||
this.letterSpacing != other.letterSpacing
|| this.wordSpacing != other.wordSpacing ||
this.textBaseline != other.textBaseline
|| this.height != other.height || this.background != other.background) {
if (color != other.color || decoration != other.decoration || decorationColor != other.decorationColor
|| decorationStyle != other.decorationStyle)
{
if (this.color != other.color || this.decoration != other.decoration ||
this.decorationColor != other.decorationColor
|| this.decorationStyle != other.decorationStyle) {
return RenderComparison.paint;
}

public ParagraphStyle getParagraphStyle(TextAlign textAlign,
TextDirection textDirection, string ellipsis, int maxLines, double textScaleFactor = 1.0)
{
TextDirection textDirection, string ellipsis, int maxLines, double textScaleFactor = 1.0) {
textAlign, textDirection, fontWeight, fontStyle,
maxLines, (fontSize ?? _defaultFontSize) * textScaleFactor,
fontFamily, height, ellipsis
textAlign, textDirection, this.fontWeight, this.fontStyle,
maxLines, (this.fontSize ?? _defaultFontSize) * textScaleFactor, this.fontFamily, this.height,
ellipsis
public TextStyle merge(TextStyle other)
{
if (other == null)
{
public TextStyle merge(TextStyle other) {
if (other == null) {
if (!other.inherit)
{
if (!other.inherit) {
D.assert(() =>
{
if (other.debugLabel != null || debugLabel != null)
{
mergedDebugLabel = string.Format("({0}).merge({1})", debugLabel ?? _kDefaultDebugLabel,
other.debugLabel ?? _kDefaultDebugLabel);
D.assert(() => {
if (other.debugLabel != null || this.debugLabel != null) {
mergedDebugLabel =
$"({this.debugLabel ?? _kDefaultDebugLabel}).merge({other.debugLabel ?? _kDefaultDebugLabel})";
return copyWith(
return this.copyWith(
color: other.color,
fontFamily: other.fontFamily,
fontSize: other.fontSize,

}
public TextStyle copyWith(Color color,
String fontFamily,
string fontFamily,
double? fontSize,
FontWeight? fontWeight,
FontStyle? fontStyle,

TextDecoration decoration = null,
Color decorationColor = null,
TextDecorationStyle? decorationStyle = null,
string debugLabel = null)
{
string debugLabel = null) {
D.assert(() =>
{
if (this.debugLabel != null)
{
newDebugLabel = debugLabel ?? string.Format("({0}).copyWith", this.debugLabel);
D.assert(() => {
if (this.debugLabel != null) {
newDebugLabel = debugLabel ?? $"({this.debugLabel}).copyWith";
}
return true;

inherit: inherit,
inherit: this.inherit,
color: color ?? this.color,
fontFamily: fontFamily ?? this.fontFamily,
fontSize: fontSize ?? this.fontSize,

);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties)
{
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
styles.Add(new DiagnosticsProperty<Color>("color", color, defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new StringProperty("family", fontFamily, defaultValue: Diagnostics.kNullDefaultValue, quoted: false));
styles.Add(new DiagnosticsProperty<double?>("size", fontSize, defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new DiagnosticsProperty<Color>("color", this.color,
defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new StringProperty("family", this.fontFamily, defaultValue: Diagnostics.kNullDefaultValue,
quoted: false));
styles.Add(new DiagnosticsProperty<double?>("size", this.fontSize,
defaultValue: Diagnostics.kNullDefaultValue));
if (fontWeight != null)
{
switch (fontWeight)
{
if (this.fontWeight != null) {
switch (this.fontWeight) {
case FontWeight.w400:
weightDescription = "400";
break;

}
styles.Add(new DiagnosticsProperty<FontWeight?>(
"weight",
fontWeight,
"weight", this.fontWeight,
styles.Add(new EnumProperty<FontStyle?>("style", fontStyle, defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new DiagnosticsProperty<double?>("letterSpacing", letterSpacing, defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new DiagnosticsProperty<double?>("wordSpacing", wordSpacing, defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new EnumProperty<TextBaseline?>("baseline", textBaseline, defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new DiagnosticsProperty<double?>("height", height, defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new StringProperty("background", background == null ? null : background.ToString(), defaultValue: Diagnostics.kNullDefaultValue, quoted: false));
if (decoration != null)
{
styles.Add(new EnumProperty<FontStyle?>("style", this.fontStyle,
defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new DiagnosticsProperty<double?>("letterSpacing", this.letterSpacing,
defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new DiagnosticsProperty<double?>("wordSpacing", this.wordSpacing,
defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new EnumProperty<TextBaseline?>("baseline", this.textBaseline,
defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new DiagnosticsProperty<double?>("height", this.height,
defaultValue: Diagnostics.kNullDefaultValue));
styles.Add(new StringProperty("background", this.background == null ? null : this.background.ToString(),
defaultValue: Diagnostics.kNullDefaultValue, quoted: false));
if (this.decoration != null) {
if (decorationStyle != null)
{
decorationDescription.Add(decorationStyle.ToString());
if (this.decorationStyle != null) {
decorationDescription.Add(this.decorationStyle.ToString());
styles.Add(new DiagnosticsProperty<Color>("decorationColor", decorationColor, defaultValue: Diagnostics.kNullDefaultValue,
styles.Add(new DiagnosticsProperty<Color>("decorationColor", this.decorationColor,
defaultValue: Diagnostics.kNullDefaultValue,
if (decorationColor != null)
{
decorationDescription.Add(decorationColor.ToString());
if (this.decorationColor != null) {
decorationDescription.Add(this.decorationColor.ToString());
styles.Add(new DiagnosticsProperty<TextDecoration>("decoration", decoration, defaultValue: Diagnostics.kNullDefaultValue,
styles.Add(new DiagnosticsProperty<TextDecoration>("decoration", this.decoration,
defaultValue: Diagnostics.kNullDefaultValue,
if (decoration != null)
if (this.decoration != null) {
}
properties.add(new DiagnosticsProperty<bool>("inherit", inherit,
level: (!styleSpecified && inherit) ? DiagnosticLevel.fine : DiagnosticLevel.info));
foreach (var style in styles)
{
properties.add(new DiagnosticsProperty<bool>("inherit", this.inherit,
level: (!styleSpecified && this.inherit) ? DiagnosticLevel.fine : DiagnosticLevel.info));
foreach (var style in styles) {
if (!styleSpecified)
properties.add(new FlagProperty("inherit", value: inherit, ifTrue: "<all styles inherited>",
if (!styleSpecified) {
properties.add(new FlagProperty("inherit", value: this.inherit, ifTrue: "<all styles inherited>",
}
public bool Equals(TextStyle other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return inherit == other.inherit && Equals(color, other.color) && fontSize.Equals(other.fontSize) &&
fontWeight == other.fontWeight && fontStyle == other.fontStyle &&
letterSpacing.Equals(other.letterSpacing) && wordSpacing.Equals(other.wordSpacing) &&
textBaseline == other.textBaseline && height.Equals(other.height) &&
Equals(decoration, other.decoration) && Equals(decorationColor, other.decorationColor) &&
decorationStyle == other.decorationStyle && Equals(background, other.background) &&
string.Equals(fontFamily, other.fontFamily);
public bool Equals(TextStyle other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.inherit == other.inherit && Equals(this.color, other.color) &&
this.fontSize.Equals(other.fontSize) && this.fontWeight == other.fontWeight &&
this.fontStyle == other.fontStyle && this.letterSpacing.Equals(other.letterSpacing) &&
this.wordSpacing.Equals(other.wordSpacing) && this.textBaseline == other.textBaseline &&
this.height.Equals(other.height) &&
Equals(this.decoration, other.decoration) &&
Equals(this.decorationColor, other.decorationColor) &&
this.decorationStyle == other.decorationStyle && Equals(this.background, other.background) &&
string.Equals(this.fontFamily, other.fontFamily);
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((TextStyle) obj);
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((TextStyle) obj);
public override int GetHashCode()
{
unchecked
{
var hashCode = inherit.GetHashCode();
hashCode = (hashCode * 397) ^ (color != null ? color.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ fontSize.GetHashCode();
hashCode = (hashCode * 397) ^ fontWeight.GetHashCode();
hashCode = (hashCode * 397) ^ fontStyle.GetHashCode();
hashCode = (hashCode * 397) ^ letterSpacing.GetHashCode();
hashCode = (hashCode * 397) ^ wordSpacing.GetHashCode();
hashCode = (hashCode * 397) ^ textBaseline.GetHashCode();
hashCode = (hashCode * 397) ^ height.GetHashCode();
hashCode = (hashCode * 397) ^ (decoration != null ? decoration.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (decorationColor != null ? decorationColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ decorationStyle.GetHashCode();
hashCode = (hashCode * 397) ^ (background != null ? background.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (fontFamily != null ? fontFamily.GetHashCode() : 0);
public override int GetHashCode() {
unchecked {
var hashCode = this.inherit.GetHashCode();
hashCode = (hashCode * 397) ^ (this.color != null ? this.color.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ this.fontSize.GetHashCode();
hashCode = (hashCode * 397) ^ this.fontWeight.GetHashCode();
hashCode = (hashCode * 397) ^ this.fontStyle.GetHashCode();
hashCode = (hashCode * 397) ^ this.letterSpacing.GetHashCode();
hashCode = (hashCode * 397) ^ this.wordSpacing.GetHashCode();
hashCode = (hashCode * 397) ^ this.textBaseline.GetHashCode();
hashCode = (hashCode * 397) ^ this.height.GetHashCode();
hashCode = (hashCode * 397) ^ (this.decoration != null ? this.decoration.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.decorationColor != null ? this.decorationColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ this.decorationStyle.GetHashCode();
hashCode = (hashCode * 397) ^ (this.background != null ? this.background.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.fontFamily != null ? this.fontFamily.GetHashCode() : 0);
public static bool operator ==(TextStyle left, TextStyle right)
{
public static bool operator ==(TextStyle left, TextStyle right) {
public static bool operator !=(TextStyle left, TextStyle right)
{
public static bool operator !=(TextStyle left, TextStyle right) {
public override string toStringShort()
{
public override string toStringShort() {
}
}

2
Runtime/physics/clamped_simulation.cs


return this.simulation.isDone(time);
}
}
}
}

4
Runtime/physics/friction_simulation.cs


D.assert((endPosition - startPosition).sign() == startVelocity.sign());
return new FrictionSimulation(
FrictionSimulation._dragFor(startPosition, endPosition, startVelocity, endVelocity),
_dragFor(startPosition, endPosition, startVelocity, endVelocity),
startPosition,
startVelocity,
tolerance: new Tolerance(velocity: endVelocity.abs())

(this.x(time) - this._maxX).abs() < this.tolerance.distance;
}
}
}
}

2
Runtime/physics/gravity_simulation.cs


return this.x(time).abs() >= this._end;
}
}
}
}

2
Runtime/physics/simulation.cs


public Tolerance tolerance;
}
}
}

13
Runtime/physics/spring_simulation.cs


public readonly double damping;
public override string ToString() {
return string.Format("{0}(mass {1:F1}, stiffness: {2:F1}, damping: {3:F1})",
this.GetType(), this.mass, this.stiffness, this.damping);
return $"{this.GetType()}(mass {this.mass:F1}, stiffness: {this.stiffness:F1}, damping: {this.damping:F1})";
}
}

}
public override string ToString() {
return string.Format("{0}(end: {1}, {2}", this.GetType(), this._endPosition, this.type);
return $"{this.GetType()}(end: {this._endPosition}, {this.type}";
}
}

return new _CriticalSolution(r, c1, c2);
}
private _CriticalSolution(
_CriticalSolution(
double r, double c1, double c2
) {
this._r = r;

return new _OverdampedSolution(r1, r2, c1, c2);
}
private _OverdampedSolution(
_OverdampedSolution(
double r1, double r2, double c1, double c2
) {
this._r1 = r1;

return new _UnderdampedSolution(w, r, c1, c2);
}
private _UnderdampedSolution(
_UnderdampedSolution(
double w, double r, double c1, double c2
) {
this._w = w;

get { return SpringType.underDamped; }
}
}
}
}

5
Runtime/physics/tolerance.cs


public readonly double velocity;
public override string ToString() {
return string.Format("Tolerance(distance: ±{0}, time: ±{1}, velocity: ±{2})",
this.distance, this.time, this.velocity);
return $"Tolerance(distance: ±{this.distance}, time: ±{this.time}, velocity: ±{this.velocity})";
}
}

2
Runtime/physics/utils.cs


return nearEqual(a, 0.0, epsilon);
}
}
}
}

2
Runtime/promise/EnumerableExt.cs


}
}
}
}
}

526
Runtime/promise/Promise.cs


using RSG.Promises;
using RSG.Promises;
namespace RSG
{
namespace RSG {
public interface IPromise<PromisedT>
{
public interface IPromise<PromisedT> {
/// <summary>
/// Gets the id of the promise, useful for referencing the promise during runtime.
/// </summary>

/// The resolved callback chains a value promise (optionally converting to a different value type).
/// </summary>
IPromise<ConvertedT> Then<ConvertedT>(
Func<PromisedT, IPromise<ConvertedT>> onResolved,
Func<PromisedT, IPromise<ConvertedT>> onResolved,
Func<Exception, IPromise<ConvertedT>> onRejected
);

/// <summary>
/// Interface for a promise that can be rejected.
/// </summary>
public interface IRejectable
{
public interface IRejectable {
/// <summary>
/// Reject the promise with an exception.
/// </summary>

/// <summary>
/// Interface for a promise that can be rejected or resolved.
/// </summary>
public interface IPendingPromise<PromisedT> : IRejectable
{
public interface IPendingPromise<PromisedT> : IRejectable {
/// <summary>
/// ID of the promise, useful for debugging.
/// </summary>

/// <summary>
/// Specifies the state of a promise.
/// </summary>
public enum PromiseState
{
Pending, // The promise is in-flight.
Rejected, // The promise has been rejected.
Resolved // The promise has been resolved.
public enum PromiseState {
Pending, // The promise is in-flight.
Rejected, // The promise has been rejected.
Resolved // The promise has been resolved.
};
/// <summary>

public class Promise<PromisedT> : IPromise<PromisedT>, IPendingPromise<PromisedT>, IPromiseInfo
{
public class Promise<PromisedT> : IPromise<PromisedT>, IPendingPromise<PromisedT>, IPromiseInfo {
private Exception rejectionException;
Exception rejectionException;
private PromisedT resolveValue;
PromisedT resolveValue;
private List<RejectHandler> rejectHandlers;
List<RejectHandler> rejectHandlers;
private List<ProgressHandler> progressHandlers;
List<ProgressHandler> progressHandlers;
private List<Action<PromisedT>> resolveCallbacks;
private List<IRejectable> resolveRejectables;
List<Action<PromisedT>> resolveCallbacks;
List<IRejectable> resolveRejectables;
public int Id { get { return id; } }
public int Id {
get { return this.id; }
}
private readonly int id;
readonly int id;
/// <summary>
/// Name of the promise, when set, useful for debugging.

/// Tracks the current state of the promise.
/// </summary>
public PromiseState CurState { get; private set; }
public bool IsSync { get; }
public Promise(bool isSync = false) {

if (Promise.EnablePromiseTracking)
{
if (Promise.EnablePromiseTracking) {
Promise.PendingPromises.Add(this);
}
}

this.CurState = PromiseState.Pending;
this.id = Promise.NextId();
if (Promise.EnablePromiseTracking)
{
if (Promise.EnablePromiseTracking) {
try
{
resolver(Resolve, Reject);
}
catch (Exception ex)
{
Reject(ex);
try {
resolver(this.Resolve, this.Reject);
} catch (Exception ex) {
this.Reject(ex);
}
}

private void AddRejectHandler(Action<Exception> onRejected, IRejectable rejectable)
{
if (rejectHandlers == null)
{
rejectHandlers = new List<RejectHandler>();
void AddRejectHandler(Action<Exception> onRejected, IRejectable rejectable) {
if (this.rejectHandlers == null) {
this.rejectHandlers = new List<RejectHandler>();
rejectHandlers.Add(new RejectHandler { callback = onRejected, rejectable = rejectable });
this.rejectHandlers.Add(new RejectHandler {callback = onRejected, rejectable = rejectable});
private void AddResolveHandler(Action<PromisedT> onResolved, IRejectable rejectable)
{
if (resolveCallbacks == null)
{
resolveCallbacks = new List<Action<PromisedT>>();
void AddResolveHandler(Action<PromisedT> onResolved, IRejectable rejectable) {
if (this.resolveCallbacks == null) {
this.resolveCallbacks = new List<Action<PromisedT>>();
if (resolveRejectables == null)
{
resolveRejectables = new List<IRejectable>();
if (this.resolveRejectables == null) {
this.resolveRejectables = new List<IRejectable>();
resolveCallbacks.Add(onResolved);
resolveRejectables.Add(rejectable);
this.resolveCallbacks.Add(onResolved);
this.resolveRejectables.Add(rejectable);
private void AddProgressHandler(Action<float> onProgress, IRejectable rejectable)
{
if (progressHandlers == null)
{
progressHandlers = new List<ProgressHandler>();
void AddProgressHandler(Action<float> onProgress, IRejectable rejectable) {
if (this.progressHandlers == null) {
this.progressHandlers = new List<ProgressHandler>();
progressHandlers.Add(new ProgressHandler { callback = onProgress, rejectable = rejectable });
this.progressHandlers.Add(new ProgressHandler {callback = onProgress, rejectable = rejectable});
private void InvokeHandler<T>(Action<T> callback, IRejectable rejectable, T value)
{
void InvokeHandler<T>(Action<T> callback, IRejectable rejectable, T value) {
try
{
try {
}
catch (Exception ex)
{
} catch (Exception ex) {
rejectable.Reject(ex);
}
}

/// </summary>
private void ClearHandlers()
{
rejectHandlers = null;
resolveCallbacks = null;
resolveRejectables = null;
progressHandlers = null;
void ClearHandlers() {
this.rejectHandlers = null;
this.resolveCallbacks = null;
this.resolveRejectables = null;
this.progressHandlers = null;
private void InvokeRejectHandlers(Exception ex)
{
void InvokeRejectHandlers(Exception ex) {
if (rejectHandlers != null)
{
rejectHandlers.Each(handler => InvokeHandler(handler.callback, handler.rejectable, ex));
if (this.rejectHandlers != null) {
this.rejectHandlers.Each(handler => this.InvokeHandler(handler.callback, handler.rejectable, ex));
ClearHandlers();
this.ClearHandlers();
private void InvokeResolveHandlers(PromisedT value)
{
if (resolveCallbacks != null)
{
for (int i = 0, maxI = resolveCallbacks.Count; i < maxI; i++) {
InvokeHandler(resolveCallbacks[i], resolveRejectables[i], value);
void InvokeResolveHandlers(PromisedT value) {
if (this.resolveCallbacks != null) {
for (int i = 0, maxI = this.resolveCallbacks.Count; i < maxI; i++) {
this.InvokeHandler(this.resolveCallbacks[i], this.resolveRejectables[i], value);
ClearHandlers();
this.ClearHandlers();
private void InvokeProgressHandlers(float progress)
{
if (progressHandlers != null)
{
progressHandlers.Each(handler => InvokeHandler(handler.callback, handler.rejectable, progress));
void InvokeProgressHandlers(float progress) {
if (this.progressHandlers != null) {
this.progressHandlers.Each(
handler => this.InvokeHandler(handler.callback, handler.rejectable, progress));
}
}

public void Reject(Exception ex) {
if (IsSync) {
RejectSync(ex);
if (this.IsSync) {
this.RejectSync(ex);
Window.instance.run(() => RejectSync(ex));
Window.instance.run(() => this.RejectSync(ex));
}
}

if (CurState != PromiseState.Pending) {
if (this.CurState != PromiseState.Pending) {
+ CurState
+ this.CurState
rejectionException = ex;
CurState = PromiseState.Rejected;
this.rejectionException = ex;
this.CurState = PromiseState.Rejected;
InvokeRejectHandlers(ex);
this.InvokeRejectHandlers(ex);
}
/// <summary>

if (IsSync) {
ResolveSync(value);
if (this.IsSync) {
this.ResolveSync(value);
Window.instance.run(() => ResolveSync(value));
Window.instance.run(() => this.ResolveSync(value));
if (CurState != PromiseState.Pending) {
if (this.CurState != PromiseState.Pending) {
+ CurState
+ this.CurState
resolveValue = value;
CurState = PromiseState.Resolved;
this.resolveValue = value;
this.CurState = PromiseState.Resolved;
InvokeResolveHandlers(value);
this.InvokeResolveHandlers(value);
public void ReportProgress(float progress)
{
if (CurState != PromiseState.Pending)
{
public void ReportProgress(float progress) {
if (this.CurState != PromiseState.Pending) {
"Attempt to report progress on a promise that is already in state: "
+ CurState + ", a promise can only report progress when it is still in state: "
"Attempt to report progress on a promise that is already in state: "
+ this.CurState + ", a promise can only report progress when it is still in state: "
InvokeProgressHandlers(progress);
this.InvokeProgressHandlers(progress);
}
/// <summary>

/// </summary>
public void Done(Action<PromisedT> onResolved, Action<Exception> onRejected)
{
Then(onResolved, onRejected)
public void Done(Action<PromisedT> onResolved, Action<Exception> onRejected) {
this.Then(onResolved, onRejected)
.Catch(ex =>
Promise.PropagateUnhandledException(this, ex)
);

/// onResolved is called on successful completion.
/// Adds a default error handler.
/// </summary>
public void Done(Action<PromisedT> onResolved)
{
Then(onResolved)
public void Done(Action<PromisedT> onResolved) {
this.Then(onResolved)
.Catch(ex =>
Promise.PropagateUnhandledException(this, ex)
);

/// Complete the promise. Adds a default error handler.
/// </summary>
public void Done()
{
Catch(ex =>
public void Done() {
this.Catch(ex =>
Promise.PropagateUnhandledException(this, ex)
);
}

/// </summary>
public IPromise<PromisedT> WithName(string name)
{
public IPromise<PromisedT> WithName(string name) {
this.Name = name;
return this;
}

/// </summary>
public IPromise Catch(Action<Exception> onRejected)
{
public IPromise Catch(Action<Exception> onRejected) {
resultPromise.WithName(Name);
resultPromise.WithName(this.Name);
Action<Exception> rejectHandler = ex =>
{
try
{
Action<Exception> rejectHandler = ex => {
try {
}
catch(Exception cbEx)
{
} catch (Exception cbEx) {
ActionHandlers(resultPromise, resolveHandler, rejectHandler);
ProgressHandlers(resultPromise, v => resultPromise.ReportProgress(v));
this.ActionHandlers(resultPromise, resolveHandler, rejectHandler);
this.ProgressHandlers(resultPromise, v => resultPromise.ReportProgress(v));
return resultPromise;
}

/// </summary>
public IPromise<PromisedT> Catch(Func<Exception, PromisedT> onRejected)
{
public IPromise<PromisedT> Catch(Func<Exception, PromisedT> onRejected) {
resultPromise.WithName(Name);
resultPromise.WithName(this.Name);
Action<Exception> rejectHandler = ex =>
{
try
{
Action<Exception> rejectHandler = ex => {
try {
}
catch (Exception cbEx)
{
} catch (Exception cbEx) {
ActionHandlers(resultPromise, resolveHandler, rejectHandler);
ProgressHandlers(resultPromise, v => resultPromise.ReportProgress(v));
this.ActionHandlers(resultPromise, resolveHandler, rejectHandler);
this.ProgressHandlers(resultPromise, v => resultPromise.ReportProgress(v));
return resultPromise;
}

/// </summary>
public IPromise<ConvertedT> Then<ConvertedT>(Func<PromisedT, IPromise<ConvertedT>> onResolved)
{
return Then(onResolved, null, null);
public IPromise<ConvertedT> Then<ConvertedT>(Func<PromisedT, IPromise<ConvertedT>> onResolved) {
return this.Then(onResolved, null, null);
public IPromise Then(Func<PromisedT, IPromise> onResolved)
{
return Then(onResolved, null, null);
public IPromise Then(Func<PromisedT, IPromise> onResolved) {
return this.Then(onResolved, null, null);
public IPromise Then(Action<PromisedT> onResolved)
{
return Then(onResolved, null, null);
public IPromise Then(Action<PromisedT> onResolved) {
return this.Then(onResolved, null, null);
}
/// <summary>

public IPromise<ConvertedT> Then<ConvertedT>(
Func<PromisedT, IPromise<ConvertedT>> onResolved,
Func<Exception, IPromise<ConvertedT>> onRejected
)
{
return Then(onResolved, onRejected, null);
) {
return this.Then(onResolved, onRejected, null);
}
/// <summary>

public IPromise Then(Func<PromisedT, IPromise> onResolved, Action<Exception> onRejected)
{
return Then(onResolved, onRejected, null);
public IPromise Then(Func<PromisedT, IPromise> onResolved, Action<Exception> onRejected) {
return this.Then(onResolved, onRejected, null);
public IPromise Then(Action<PromisedT> onResolved, Action<Exception> onRejected)
{
return Then(onResolved, onRejected, null);
public IPromise Then(Action<PromisedT> onResolved, Action<Exception> onRejected) {
return this.Then(onResolved, onRejected, null);
}

/// </summary>
public IPromise<ConvertedT> Then<ConvertedT>(
Func<PromisedT, IPromise<ConvertedT>> onResolved,
Func<PromisedT, IPromise<ConvertedT>> onResolved,
)
{
) {
resultPromise.WithName(Name);
resultPromise.WithName(this.Name);
Action<PromisedT> resolveHandler = v =>
{
Action<PromisedT> resolveHandler = v => {
onResolved(v)
.Progress(progress => resultPromise.ReportProgress(progress))
.Then(

);
};
Action<Exception> rejectHandler = ex =>
{
if (onRejected == null)
{
Action<Exception> rejectHandler = ex => {
if (onRejected == null) {
try
{
try {
}
catch (Exception callbackEx)
{
} catch (Exception callbackEx) {
ActionHandlers(resultPromise, resolveHandler, rejectHandler);
if (onProgress != null)
{
ProgressHandlers(this, onProgress);
this.ActionHandlers(resultPromise, resolveHandler, rejectHandler);
if (onProgress != null) {
this.ProgressHandlers(this, onProgress);
}
return resultPromise;

/// Add a resolved callback, a rejected callback and a progress callback.
/// The resolved callback chains a non-value promise.
/// </summary>
public IPromise Then(Func<PromisedT, IPromise> onResolved, Action<Exception> onRejected, Action<float> onProgress)
{
public IPromise Then(Func<PromisedT, IPromise> onResolved, Action<Exception> onRejected,
Action<float> onProgress) {
resultPromise.WithName(Name);
resultPromise.WithName(this.Name);
Action<PromisedT> resolveHandler = v =>
{
if (onResolved != null)
{
Action<PromisedT> resolveHandler = v => {
if (onResolved != null) {
onResolved(v)
.Progress(progress => resultPromise.ReportProgress(progress))
.Then(

}
else
{
} else {
Action<Exception> rejectHandler = ex =>
{
if (onRejected != null)
{
Action<Exception> rejectHandler = ex => {
if (onRejected != null) {
onRejected(ex);
}

ActionHandlers(resultPromise, resolveHandler, rejectHandler);
if (onProgress != null)
{
ProgressHandlers(this, onProgress);
this.ActionHandlers(resultPromise, resolveHandler, rejectHandler);
if (onProgress != null) {
this.ProgressHandlers(this, onProgress);
}
return resultPromise;

/// Add a resolved callback, a rejected callback and a progress callback.
/// </summary>
public IPromise Then(Action<PromisedT> onResolved, Action<Exception> onRejected, Action<float> onProgress)
{
public IPromise Then(Action<PromisedT> onResolved, Action<Exception> onRejected, Action<float> onProgress) {
resultPromise.WithName(Name);
resultPromise.WithName(this.Name);
Action<PromisedT> resolveHandler = v =>
{
if (onResolved != null)
{
Action<PromisedT> resolveHandler = v => {
if (onResolved != null) {
onResolved(v);
}

Action<Exception> rejectHandler = ex =>
{
if (onRejected != null)
{
Action<Exception> rejectHandler = ex => {
if (onRejected != null) {
onRejected(ex);
}

ActionHandlers(resultPromise, resolveHandler, rejectHandler);
if (onProgress != null)
{
ProgressHandlers(this, onProgress);
this.ActionHandlers(resultPromise, resolveHandler, rejectHandler);
if (onProgress != null) {
this.ProgressHandlers(this, onProgress);
}
return resultPromise;

/// Return a new promise with a different value.
/// May also change the type of the value.
/// </summary>
public IPromise<ConvertedT> Then<ConvertedT>(Func<PromisedT, ConvertedT> transform)
{
public IPromise<ConvertedT> Then<ConvertedT>(Func<PromisedT, ConvertedT> transform) {
return Then(value => Promise<ConvertedT>.Resolved(transform(value)));
return this.Then(value => Promise<ConvertedT>.Resolved(transform(value)));
private void ActionHandlers(IRejectable resultPromise, Action<PromisedT> resolveHandler, Action<Exception> rejectHandler)
{
if (CurState == PromiseState.Resolved) {
InvokeHandler(resolveHandler, resultPromise, resolveValue);
}
else if (CurState == PromiseState.Rejected) {
InvokeHandler(rejectHandler, resultPromise, rejectionException);
}
else {
AddResolveHandler(resolveHandler, resultPromise);
AddRejectHandler(rejectHandler, resultPromise);
void ActionHandlers(IRejectable resultPromise, Action<PromisedT> resolveHandler,
Action<Exception> rejectHandler) {
if (this.CurState == PromiseState.Resolved) {
this.InvokeHandler(resolveHandler, resultPromise, this.resolveValue);
} else if (this.CurState == PromiseState.Rejected) {
this.InvokeHandler(rejectHandler, resultPromise, this.rejectionException);
} else {
this.AddResolveHandler(resolveHandler, resultPromise);
this.AddRejectHandler(rejectHandler, resultPromise);
}
}

private void ProgressHandlers(IRejectable resultPromise, Action<float> progressHandler)
{
if (CurState == PromiseState.Pending)
{
AddProgressHandler(progressHandler, resultPromise);
void ProgressHandlers(IRejectable resultPromise, Action<float> progressHandler) {
if (this.CurState == PromiseState.Pending) {
this.AddProgressHandler(progressHandler, resultPromise);
}
}

/// The resulting promise is resolved when all of the promises have resolved.
/// It is rejected as soon as any of the promises have been rejected.
/// </summary>
public IPromise<IEnumerable<ConvertedT>> ThenAll<ConvertedT>(Func<PromisedT, IEnumerable<IPromise<ConvertedT>>> chain)
{
return Then(value => Promise<ConvertedT>.All(chain(value)));
public IPromise<IEnumerable<ConvertedT>> ThenAll<ConvertedT>(
Func<PromisedT, IEnumerable<IPromise<ConvertedT>>> chain) {
return this.Then(value => Promise<ConvertedT>.All(chain(value)));
}
/// <summary>

/// It is rejected as soon as any of the promises have been rejected.
/// </summary>
public IPromise ThenAll(Func<PromisedT, IEnumerable<IPromise>> chain)
{
return Then(value => Promise.All(chain(value)));
public IPromise ThenAll(Func<PromisedT, IEnumerable<IPromise>> chain) {
return this.Then(value => Promise.All(chain(value)));
}
/// <summary>

public static IPromise<IEnumerable<PromisedT>> All(params IPromise<PromisedT>[] promises)
{
return All((IEnumerable<IPromise<PromisedT>>)promises); // Cast is required to force use of the other All function.
public static IPromise<IEnumerable<PromisedT>> All(params IPromise<PromisedT>[] promises) {
return
All(
(IEnumerable<IPromise<PromisedT>>)
promises); // Cast is required to force use of the other All function.
}
/// <summary>

public static IPromise<IEnumerable<PromisedT>> All(IEnumerable<IPromise<PromisedT>> promises)
{
public static IPromise<IEnumerable<PromisedT>> All(IEnumerable<IPromise<PromisedT>> promises) {
if (promisesArray.Length == 0)
{
if (promisesArray.Length == 0) {
return Promise<IEnumerable<PromisedT>>.Resolved(Enumerable.Empty<PromisedT>());
}

var resultPromise = new Promise<IEnumerable<PromisedT>>();
resultPromise.WithName("All");
promisesArray.Each((promise, index) =>
{
promisesArray.Each((promise, index) => {
.Progress(v =>
{
.Progress(v => {
if (resultPromise.CurState == PromiseState.Pending)
{
if (resultPromise.CurState == PromiseState.Pending) {
.Then(result =>
{
.Then(result => {
if (remainingCount <= 0 && resultPromise.CurState == PromiseState.Pending)
{
if (remainingCount <= 0 && resultPromise.CurState == PromiseState.Pending) {
.Catch(ex =>
{
if (resultPromise.CurState == PromiseState.Pending)
{
.Catch(ex => {
if (resultPromise.CurState == PromiseState.Pending) {
// If a promise errorred and the result promise is still pending, reject it.
resultPromise.Reject(ex);
}

/// Returns a promise that resolves when the first of the promises has resolved.
/// Yields the value from the first promise that has resolved.
/// </summary>
public IPromise<ConvertedT> ThenRace<ConvertedT>(Func<PromisedT, IEnumerable<IPromise<ConvertedT>>> chain)
{
return Then(value => Promise<ConvertedT>.Race(chain(value)));
public IPromise<ConvertedT> ThenRace<ConvertedT>(Func<PromisedT, IEnumerable<IPromise<ConvertedT>>> chain) {
return this.Then(value => Promise<ConvertedT>.Race(chain(value)));
}
/// <summary>

/// Yields the value from the first promise that has resolved.
/// </summary>
public IPromise ThenRace(Func<PromisedT, IEnumerable<IPromise>> chain)
{
return Then(value => Promise.Race(chain(value)));
public IPromise ThenRace(Func<PromisedT, IEnumerable<IPromise>> chain) {
return this.Then(value => Promise.Race(chain(value)));
}
/// <summary>

public static IPromise<PromisedT> Race(params IPromise<PromisedT>[] promises)
{
return Race((IEnumerable<IPromise<PromisedT>>)promises); // Cast is required to force use of the other function.
public static IPromise<PromisedT> Race(params IPromise<PromisedT>[] promises) {
return
Race(
(IEnumerable<IPromise<PromisedT>>)
promises); // Cast is required to force use of the other function.
}
/// <summary>

public static IPromise<PromisedT> Race(IEnumerable<IPromise<PromisedT>> promises)
{
public static IPromise<PromisedT> Race(IEnumerable<IPromise<PromisedT>> promises) {
if (promisesArray.Length == 0)
{
if (promisesArray.Length == 0) {
throw new InvalidOperationException(
"At least 1 input promise must be provided for Race"
);

var progress = new float[promisesArray.Length];
promisesArray.Each((promise, index) =>
{
promisesArray.Each((promise, index) => {
.Progress(v =>
{
if (resultPromise.CurState == PromiseState.Pending)
{
.Progress(v => {
if (resultPromise.CurState == PromiseState.Pending) {
.Then(result =>
{
if (resultPromise.CurState == PromiseState.Pending)
{
.Then(result => {
if (resultPromise.CurState == PromiseState.Pending) {
.Catch(ex =>
{
if (resultPromise.CurState == PromiseState.Pending)
{
.Catch(ex => {
if (resultPromise.CurState == PromiseState.Pending) {
// If a promise errorred and the result promise is still pending, reject it.
resultPromise.Reject(ex);
}

/// <summary>
/// Convert a simple value directly into a resolved promise.
/// </summary>
public static IPromise<PromisedT> Resolved(PromisedT promisedValue)
{
public static IPromise<PromisedT> Resolved(PromisedT promisedValue) {
var promise = new Promise<PromisedT>(isSync: true);
promise.Resolve(promisedValue);
return promise;

/// Convert an exception directly into a rejected promise.
/// </summary>
public static IPromise<PromisedT> Rejected(Exception ex)
{
public static IPromise<PromisedT> Rejected(Exception ex) {
// Argument.NotNull(() => ex);
var promise = new Promise<PromisedT>();

public IPromise<PromisedT> Finally(Action onComplete)
{
public IPromise<PromisedT> Finally(Action onComplete) {
promise.WithName(Name);
promise.WithName(this.Name);
this.Then(x => promise.Resolve(x));
this.Catch(e => {

}
});
return promise.Then(v =>
{
return promise.Then(v => {
public IPromise ContinueWith(Func<IPromise> onComplete)
{
public IPromise ContinueWith(Func<IPromise> onComplete) {
promise.WithName(Name);
promise.WithName(this.Name);
this.Then(x => promise.Resolve());
this.Catch(e => promise.Resolve());

public IPromise<ConvertedT> ContinueWith<ConvertedT>(Func<IPromise<ConvertedT>> onComplete)
{
public IPromise<ConvertedT> ContinueWith<ConvertedT>(Func<IPromise<ConvertedT>> onComplete) {
promise.WithName(Name);
promise.WithName(this.Name);
this.Then(x => promise.Resolve());
this.Catch(e => promise.Resolve());

public IPromise<PromisedT> Progress(Action<float> onProgress)
{
if (onProgress != null)
{
ProgressHandlers(this, onProgress);
public IPromise<PromisedT> Progress(Action<float> onProgress) {
if (onProgress != null) {
this.ProgressHandlers(this, onProgress);
}
}

20
Runtime/promise/PromiseException.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RSG.Exceptions
{
namespace RSG.Exceptions {
public class PromiseException : Exception
{
public PromiseException() { }
public class PromiseException : Exception {
public PromiseException() {
}
public PromiseException(string message) : base(message) { }
public PromiseException(string message) : base(message) {
}
public PromiseException(string message, Exception inner) : base(message, inner) { }
public PromiseException(string message, Exception inner) : base(message, inner) {
}
}
}

2
Runtime/promise/PromiseHelpers.cs


.Then(vals => Tuple.Create(vals.Item1.Item1, vals.Item1.Item2, vals.Item2.Item1, vals.Item2.Item2));
}
}
}
}

5
Runtime/promise/PromiseStateException.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RSG.Exceptions {
/// <summary>

: base(message, inner) {
}
}
}
}

52
Runtime/promise/PromiseTimer.cs


/// Create the exception with description
/// </summary>
/// <param name="message">Exception description</param>
public PromiseCancelledException(String message) : base(message) {
public PromiseCancelledException(string message) : base(message) {
}
}

internal class PredicateWait {
class PredicateWait {
/// <summary>
/// Predicate for resolving the promise
/// </summary>

/// <summary>
/// The current running total for time that this PromiseTimer has run for
/// </summary>
private float curTime;
float curTime;
private int curFrame;
int curFrame;
private readonly LinkedList<PredicateWait> waiting = new LinkedList<PredicateWait>();
readonly LinkedList<PredicateWait> waiting = new LinkedList<PredicateWait>();
return WaitUntil(t => t.elapsedTime >= seconds);
return this.WaitUntil(t => t.elapsedTime >= seconds);
}
/// <summary>

return WaitUntil(t => !predicate(t));
return this.WaitUntil(t => !predicate(t));
}
/// <summary>

var promise = new Promise();
var wait = new PredicateWait() {
timeStarted = curTime,
timeStarted = this.curTime,
frameStarted = curFrame
frameStarted = this.curFrame
waiting.AddLast(wait);
this.waiting.AddLast(wait);
var node = FindInWaiting(promise);
var node = this.FindInWaiting(promise);
if (node == null) {
return false;

waiting.Remove(node);
this.waiting.Remove(node);
for (var node = waiting.First; node != null; node = node.Next) {
for (var node = this.waiting.First; node != null; node = node.Next) {
if (node.Value.pendingPromise.Id.Equals(promise.Id)) {
return node;
}

/// Update all pending promises. Must be called for the promises to progress and resolve at all.
/// </summary>
public void Update(float deltaTime) {
curTime += deltaTime;
curFrame += 1;
this.curTime += deltaTime;
this.curFrame += 1;
var node = waiting.First;
var node = this.waiting.First;
var newElapsedTime = curTime - wait.timeStarted;
var newElapsedTime = this.curTime - wait.timeStarted;
var newElapsedUpdates = curFrame - wait.frameStarted;
var newElapsedUpdates = this.curFrame - wait.frameStarted;
}
catch (Exception ex) {
} catch (Exception ex) {
node = RemoveNode(node);
node = this.RemoveNode(node);
continue;
}

node = RemoveNode(node);
}
else {
node = this.RemoveNode(node);
} else {
node = node.Next;
}
}

/// Removes the provided node and returns the next node in the list.
/// </summary>
private LinkedListNode<PredicateWait> RemoveNode(LinkedListNode<PredicateWait> node) {
LinkedListNode<PredicateWait> RemoveNode(LinkedListNode<PredicateWait> node) {
waiting.Remove(currentNode);
this.waiting.Remove(currentNode);
}
}

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存