Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 7f00096

Browse files
authored
Merge pull request #162 from UnityTech/kgdev
some fixes and improvements.
2 parents ed60ea9 + f744058 commit 7f00096

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+943
-661
lines changed

Runtime/Unity.UIWidgets.asmdef

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"name": "Unity.UIWidgets",
33
"references": [],
4+
"optionalUnityReferences": [],
45
"includePlatforms": [],
5-
"excludePlatforms": []
6-
}
6+
"excludePlatforms": [],
7+
"allowUnsafeCode": true,
8+
"overrideReferences": false,
9+
"precompiledReferences": [],
10+
"autoReferenced": true,
11+
"defineConstraints": []
12+
}

Runtime/animation/animation_controller.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public TickerFuture forward(float? from = null) {
157157
});
158158
D.assert(
159159
this._ticker != null,
160-
"AnimationController.forward() called after AnimationController.dispose()\n" +
160+
() => "AnimationController.forward() called after AnimationController.dispose()\n" +
161161
"AnimationController methods should not be used after calling dispose."
162162
);
163163
this._direction = _AnimationDirection.forward;
@@ -182,7 +182,7 @@ public TickerFuture reverse(float? from = null) {
182182
});
183183
D.assert(
184184
this._ticker != null,
185-
"AnimationController.reverse() called after AnimationController.dispose()\n" +
185+
() => "AnimationController.reverse() called after AnimationController.dispose()\n" +
186186
"AnimationController methods should not be used after calling dispose."
187187
);
188188
this._direction = _AnimationDirection.reverse;
@@ -196,7 +196,7 @@ public TickerFuture reverse(float? from = null) {
196196
public TickerFuture animateTo(float target, TimeSpan? duration = null, Curve curve = null) {
197197
D.assert(
198198
this._ticker != null,
199-
"AnimationController.animateTo() called after AnimationController.dispose()\n" +
199+
() => "AnimationController.animateTo() called after AnimationController.dispose()\n" +
200200
"AnimationController methods should not be used after calling dispose."
201201
);
202202
curve = curve ?? Curves.linear;
@@ -208,7 +208,7 @@ public TickerFuture animateTo(float target, TimeSpan? duration = null, Curve cur
208208
public TickerFuture animateBack(float target, TimeSpan? duration, Curve curve = null) {
209209
D.assert(
210210
this._ticker != null,
211-
"AnimationController.animateBack() called after AnimationController.dispose()\n" +
211+
() => "AnimationController.animateBack() called after AnimationController.dispose()\n" +
212212
"AnimationController methods should not be used after calling dispose."
213213
);
214214
curve = curve ?? Curves.linear;
@@ -300,7 +300,7 @@ public TickerFuture fling(float velocity = 1.0f) {
300300
public TickerFuture animateWith(Simulation simulation) {
301301
D.assert(
302302
this._ticker != null,
303-
"AnimationController.animateWith() called after AnimationController.dispose()\n" +
303+
() => "AnimationController.animateWith() called after AnimationController.dispose()\n" +
304304
"AnimationController methods should not be used after calling dispose."
305305
);
306306
this.stop();
@@ -324,7 +324,7 @@ TickerFuture _startSimulation(Simulation simulation) {
324324
public void stop(bool canceled = true) {
325325
D.assert(
326326
this._ticker != null,
327-
"AnimationController.stop() called after AnimationController.dispose()\n" +
327+
() => "AnimationController.stop() called after AnimationController.dispose()\n" +
328328
"AnimationController methods should not be used after calling dispose."
329329
);
330330
this._simulation = null;

Runtime/animation/animations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ void _maybeNotifyStatusListeners(AnimationStatus _) {
544544
T _lastValue;
545545

546546
void _maybeNotifyListeners() {
547-
if (Equals(this.value, this._lastValue)) {
547+
if (!Equals(this.value, this._lastValue)) {
548548
this._lastValue = this.value;
549549
this.notifyListeners();
550550
}

Runtime/animation/tween.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ protected Tween(T begin, T end) {
7070
this.end = end;
7171
}
7272

73-
public T begin;
73+
public virtual T begin { get; set; }
7474

75-
public T end;
75+
public virtual T end { get; set; }
7676

7777
public abstract T lerp(float t);
7878

Runtime/async/timer.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,43 +99,38 @@ public Timer periodic(TimeSpan duration, Action callback) {
9999
return timer;
100100
}
101101

102+
static readonly List<TimerImpl> _timers = new List<TimerImpl>();
103+
static readonly List<TimerImpl> _appendList = new List<TimerImpl>();
104+
102105
public void update(Action flushMicroTasks = null) {
103106
var now = Timer.timeSinceStartup;
104107

105-
List<TimerImpl> timers = null;
106-
List<TimerImpl> appendList = null;
107-
108+
_timers.Clear();
109+
_appendList.Clear();
110+
108111
lock (this._queue) {
109112
while (this._queue.count > 0 && this._queue.peek().deadline <= now) {
110113
var timer = this._queue.dequeue();
111-
if (timers == null) {
112-
timers = new List<TimerImpl>();
113-
}
114-
115-
timers.Add(timer);
114+
_timers.Add(timer);
116115
}
117116
}
118117

119-
if (timers != null) {
120-
foreach (var timer in timers) {
118+
if (_timers.Count != 0) {
119+
foreach (var timer in _timers) {
121120
if (flushMicroTasks != null) {
122121
flushMicroTasks();
123122
}
124123

125124
timer.invoke();
126125
if (timer.periodic && !timer.done) {
127-
if (appendList == null) {
128-
appendList = new List<TimerImpl>();
129-
}
130-
131-
appendList.Add(timer);
126+
_appendList.Add(timer);
132127
}
133128
}
134129
}
135130

136-
if (appendList != null) {
131+
if (_appendList.Count != 0) {
137132
lock (this._queue) {
138-
foreach (var timer in appendList) {
133+
foreach (var timer in _appendList) {
139134
this._queue.enqueue(timer);
140135
}
141136
}

Runtime/engine/UIWidgetsMessageManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ internal static void ensureUIWidgetsMessageManagerIfNeeded() {
3333
#endif
3434

3535
void OnEnable() {
36-
D.assert(_instance == null, "Only one instance of UIWidgetsMessageManager should exists");
36+
D.assert(_instance == null, () => "Only one instance of UIWidgetsMessageManager should exists");
3737
_instance = this;
3838
this.UpdateNameIfNeed();
3939
}
4040

4141
void OnDisable() {
42-
D.assert(_instance != null, "_instance should not be null");
42+
D.assert(_instance != null, () => "_instance should not be null");
4343
_instance = null;
4444
}
4545

Runtime/foundation/change_notifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public ValueNotifier(T value) {
115115
this._value = value;
116116
}
117117

118-
public T value {
118+
public virtual T value {
119119
get { return this._value; }
120120
set {
121121
if (Equals(value, this._value)) {

Runtime/foundation/debug.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public static bool debugEnabled {
2626
}
2727

2828
[Conditional("UIWidgets_DEBUG")]
29-
public static void assert(Func<bool> result, string message = null) {
29+
public static void assert(Func<bool> result, Func<string> message = null) {
3030
if (!result()) {
31-
throw new AssertionError(message);
31+
throw new AssertionError(message != null ? message() : "");
3232
}
3333
}
3434

3535
[Conditional("UIWidgets_DEBUG")]
36-
public static void assert(bool result, string message = null) {
36+
public static void assert(bool result, Func<string> message = null) {
3737
if (!result) {
38-
throw new AssertionError(message);
38+
throw new AssertionError(message != null ? message() : "");
3939
}
4040
}
4141

Runtime/foundation/diagnostics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ protected DiagnosticsNode(
242242
bool showSeparator = true
243243
) {
244244
D.assert(name == null || !name.EndsWith(":"),
245-
"Names of diagnostic nodes must not end with colons.");
245+
() => "Names of diagnostic nodes must not end with colons.");
246246
this.name = name;
247247
this._style = style;
248248
this._showName = showName;

Runtime/foundation/observer_list.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
namespace Unity.UIWidgets.foundation {
55
public class ObserverList<T> : ICollection<T> {
6-
public readonly List<T> _list = new List<T>();
7-
public bool _isDirty = false;
8-
public HashSet<T> _set = null;
6+
readonly List<T> _list = new List<T>();
7+
bool _isDirty = false;
8+
HashSet<T> _set = null;
99

1010
IEnumerator IEnumerable.GetEnumerator() {
1111
return this.GetEnumerator();

0 commit comments

Comments
 (0)