siyao
4 年前
当前提交
957be42a
共有 177 个文件被更改,包括 1138 次插入 和 854 次删除
-
2Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/Editor/EditorWindowSample/GalleryMain.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/BottomAppBarSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/DividerAndButton.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/HoverSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs
-
4Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/NavigatorPopSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/NetWorkImageSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/Script/CountTest.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/Script/ImageTest.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/Script/TextFieldTest.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_refresh_demo.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_segmented_control_demo.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/date_and_time_picker_demo.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/leave_behind_demo.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/overscroll_demo.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/text_form_field_demo.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/expanding_bottom_sheet.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/model/scoped_model.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/app.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demo.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/CustomPaintSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/DragDropSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ExpansionPanelSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/HttpRequestSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ImageFormatSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/LongPressSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/NavigationSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/PageViewSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ScrollbarSample.cs
-
2Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/UIWidgetsSamplePanel.cs
-
4com.unity.uiwidgets/Editor/UIWidgetsEditorPanel.cs
-
2com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs
-
267com.unity.uiwidgets/Runtime/async/timer.cs
-
2com.unity.uiwidgets/Runtime/cupertino/localization.cs
-
2com.unity.uiwidgets/Runtime/cupertino/refresh.cs
-
2com.unity.uiwidgets/Runtime/cupertino/route.cs
-
2com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs
-
103com.unity.uiwidgets/Runtime/engine/DisplayMetrics.cs
-
2com.unity.uiwidgets/Runtime/engine/UIWidgetsMessageManager.cs
-
605com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs
-
4com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs.meta
-
2com.unity.uiwidgets/Runtime/foundation/basic_types.cs
-
2com.unity.uiwidgets/Runtime/foundation/binding.cs
-
2com.unity.uiwidgets/Runtime/foundation/debug.cs
-
2com.unity.uiwidgets/Runtime/foundation/isolates.cs
-
2com.unity.uiwidgets/Runtime/foundation/synchronous_future.cs
-
2com.unity.uiwidgets/Runtime/gestures/binding.cs
-
2com.unity.uiwidgets/Runtime/gestures/multidrag.cs
-
2com.unity.uiwidgets/Runtime/gestures/multitap.cs
-
2com.unity.uiwidgets/Runtime/gestures/recognizer.cs
-
2com.unity.uiwidgets/Runtime/material/about.cs
-
2com.unity.uiwidgets/Runtime/material/bottom_sheet.cs
-
2com.unity.uiwidgets/Runtime/material/dialog.cs
-
2com.unity.uiwidgets/Runtime/material/dropdown.cs
-
2com.unity.uiwidgets/Runtime/material/feedback.cs
-
2com.unity.uiwidgets/Runtime/material/material_localizations.cs
-
2com.unity.uiwidgets/Runtime/material/pickers/date_picker_dialog.cs
-
2com.unity.uiwidgets/Runtime/material/popup_menu.cs
-
2com.unity.uiwidgets/Runtime/material/range_slider.cs
-
2com.unity.uiwidgets/Runtime/material/refresh_indicator.cs
-
2com.unity.uiwidgets/Runtime/material/scaffold.cs
-
2com.unity.uiwidgets/Runtime/material/scrollbar.cs
-
2com.unity.uiwidgets/Runtime/material/search.cs
-
2com.unity.uiwidgets/Runtime/material/selectable_text.cs
-
2com.unity.uiwidgets/Runtime/material/slider.cs
-
2com.unity.uiwidgets/Runtime/material/tabs.cs
-
2com.unity.uiwidgets/Runtime/material/time_picker.cs
-
2com.unity.uiwidgets/Runtime/material/tooltip.cs
-
2com.unity.uiwidgets/Runtime/painting/binding.cs
-
2com.unity.uiwidgets/Runtime/painting/image_decoder.cs
-
4com.unity.uiwidgets/Runtime/painting/image_provider.cs
-
2com.unity.uiwidgets/Runtime/painting/image_resolution.cs
-
2com.unity.uiwidgets/Runtime/painting/image_stream.cs
-
2com.unity.uiwidgets/Runtime/painting/shader_warmup.cs
-
2com.unity.uiwidgets/Runtime/rendering/editable.cs
-
2com.unity.uiwidgets/Runtime/rendering/layer.cs
-
2com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
-
2com.unity.uiwidgets/Runtime/rendering/viewport_offset.cs
-
655com.unity.uiwidgets/Runtime/scheduler/binding.cs
-
4com.unity.uiwidgets/Runtime/scheduler/binding.cs.meta
-
158com.unity.uiwidgets/Runtime/scheduler/ticker.cs
-
4com.unity.uiwidgets/Runtime/scheduler/ticker.cs.meta
-
4com.unity.uiwidgets/Runtime/services/asset_bundle.cs
-
2com.unity.uiwidgets/Runtime/services/binary_messenger.cs
-
2com.unity.uiwidgets/Runtime/services/binding.cs
-
2com.unity.uiwidgets/Runtime/services/clipboard.cs
-
2com.unity.uiwidgets/Runtime/services/keyboard.cs
|
|||
/* |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using System.Runtime.InteropServices; |
|||
using AOT; |
|||
using Unity.UIWidgets.ui; |
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
|
|||
#endif
|
|||
public abstract void cancel(); |
|||
|
|||
public void Dispose() { |
|||
cancel(); |
|||
} |
|||
|
|||
public static float timeSinceStartup { |
|||
get { |
|||
#if UNITY_EDITOR
|
|||
return (float) EditorApplication.timeSinceStartup; |
|||
#else
|
|||
return Time.realtimeSinceStartup; |
|||
#endif
|
|||
public static Timer create(TimeSpan duration, ZoneCallback callback) { |
|||
if (Zone.current == Zone.root) { |
|||
return Zone.current.createTimer(duration, callback); |
|||
} |
|||
public static TimeSpan timespanSinceStartup { |
|||
get { return TimeSpan.FromSeconds(timeSinceStartup); } |
|||
return Zone.current |
|||
.createTimer(duration, Zone.current.bindCallbackGuarded(callback)); |
|||
static readonly object _syncObj = new object(); |
|||
|
|||
static LinkedList<Action> _callbacks = new LinkedList<Action>(); |
|||
|
|||
public static void runInMainFromFinalizer(Action callback) { |
|||
lock (_syncObj) { |
|||
_callbacks.AddLast(callback); |
|||
} |
|||
public static Timer create(TimeSpan duration, Action callback) { |
|||
return create(duration, () => { |
|||
callback.Invoke(); |
|||
return null; |
|||
}); |
|||
internal static void update() { |
|||
LinkedList<Action> callbacks; |
|||
|
|||
lock (_syncObj) { |
|||
if (_callbacks.isEmpty()) { |
|||
return; |
|||
} |
|||
|
|||
callbacks = _callbacks; |
|||
_callbacks = new LinkedList<Action>(); |
|||
public static Timer periodic(TimeSpan duration, ZoneUnaryCallback callback) { |
|||
if (Zone.current == Zone.root) { |
|||
return Zone.current.createPeriodicTimer(duration, callback); |
|||
foreach (var callback in callbacks) { |
|||
try { |
|||
callback(); |
|||
} |
|||
catch (Exception ex) { |
|||
D.logError("Error to execute runInMain callback: ", ex); |
|||
} |
|||
} |
|||
var boundCallback = Zone.current.bindUnaryCallbackGuarded(callback); |
|||
return Zone.current.createPeriodicTimer(duration, boundCallback); |
|||
} |
|||
public class TimerProvider { |
|||
readonly PriorityQueue<TimerImpl> _queue; |
|||
|
|||
public TimerProvider() { |
|||
_queue = new PriorityQueue<TimerImpl>(); |
|||
public static void run(ZoneCallback callback) { |
|||
create(TimeSpan.Zero, callback); |
|||
public Timer runInMain(Action callback) { |
|||
var timer = new TimerImpl(callback); |
|||
public abstract void cancel(); |
|||
lock (_queue) { |
|||
_queue.enqueue(timer); |
|||
} |
|||
|
|||
return timer; |
|||
public void Dispose() { |
|||
cancel(); |
|||
public Timer run(TimeSpan duration, Action callback) { |
|||
var timer = new TimerImpl(duration, callback); |
|||
public abstract long tick { get; } |
|||
|
|||
public abstract bool isActive { get; } |
|||
lock (_queue) { |
|||
_queue.enqueue(timer); |
|||
} |
|||
internal static Timer _createTimer(TimeSpan duration, ZoneCallback callback) { |
|||
return _Timer._createTimer(_ => callback(), (int) duration.TotalMilliseconds, false); |
|||
} |
|||
return timer; |
|||
internal static Timer _createPeriodicTimer( |
|||
TimeSpan duration, ZoneUnaryCallback callback) { |
|||
return _Timer._createTimer(callback, (int) duration.TotalMilliseconds, true); |
|||
} |
|||
public Timer periodic(TimeSpan duration, Action callback) { |
|||
var timer = new TimerImpl(duration, callback, periodic: true); |
|||
class _Timer : Timer { |
|||
long _tick = 0; |
|||
lock (_queue) { |
|||
_queue.enqueue(timer); |
|||
} |
|||
ZoneUnaryCallback _callback; |
|||
long _wakeupTime; |
|||
readonly int _milliSeconds; |
|||
readonly bool _repeating; |
|||
return timer; |
|||
_Timer(ZoneUnaryCallback callback, long wakeupTime, int milliSeconds, bool repeating) { |
|||
_callback = callback; |
|||
_wakeupTime = wakeupTime; |
|||
_milliSeconds = milliSeconds; |
|||
_repeating = repeating; |
|||
|
|||
static readonly List<TimerImpl> _timers = new List<TimerImpl>(); |
|||
static readonly List<TimerImpl> _appendList = new List<TimerImpl>(); |
|||
public void update(Action flushMicroTasks = null) { |
|||
var now = Timer.timeSinceStartup; |
|||
|
|||
_timers.Clear(); |
|||
_appendList.Clear(); |
|||
lock (_queue) { |
|||
while (_queue.count > 0 && _queue.peek().deadline <= now) { |
|||
var timer = _queue.dequeue(); |
|||
_timers.Add(timer); |
|||
} |
|||
public static TimeSpan timespanSinceStartup { |
|||
get { return TimeSpan.FromMilliseconds(UIMonoState_timerMillisecondClock()); } |
|||
} |
|||
|
|||
internal static _Timer _createTimer(ZoneUnaryCallback callback, int milliSeconds, bool repeating) { |
|||
if (milliSeconds < 0) { |
|||
milliSeconds = 0; |
|||
if (_timers.Count != 0) { |
|||
foreach (var timer in _timers) { |
|||
if (flushMicroTasks != null) { |
|||
flushMicroTasks(); |
|||
} |
|||
long now = UIMonoState_timerMillisecondClock(); |
|||
long wakeupTime = (milliSeconds == 0) ? now : (now + 1 + milliSeconds); |
|||
timer.invoke(); |
|||
if (timer.periodic && !timer.done) { |
|||
_appendList.Add(timer); |
|||
} |
|||
} |
|||
} |
|||
_Timer timer = new _Timer(callback, wakeupTime, milliSeconds, repeating); |
|||
timer._enqueue(); |
|||
if (_appendList.Count != 0) { |
|||
lock (_queue) { |
|||
foreach (var timer in _appendList) { |
|||
_queue.enqueue(timer); |
|||
} |
|||
} |
|||
} |
|||
return timer; |
|||
class TimerImpl : Timer, IComparable<TimerImpl> { |
|||
float _deadline; |
|||
readonly Action _callback; |
|||
bool _done; |
|||
public override void cancel() { |
|||
_callback = null; |
|||
} |
|||
public readonly bool periodic; |
|||
readonly TimeSpan _interval; |
|||
public override bool isActive => _callback != null; |
|||
public TimerImpl(TimeSpan duration, Action callback, bool periodic = false) { |
|||
_deadline = timeSinceStartup + (float) duration.TotalSeconds; |
|||
_callback = callback; |
|||
_done = false; |
|||
public override long tick => _tick; |
|||
this.periodic = periodic; |
|||
if (periodic) { |
|||
_interval = duration; |
|||
} |
|||
void _advanceWakeupTime() { |
|||
if (_milliSeconds > 0) { |
|||
_wakeupTime += _milliSeconds; |
|||
|
|||
public TimerImpl(Action callback) { |
|||
_deadline = 0; |
|||
_callback = callback; |
|||
_done = false; |
|||
else { |
|||
_wakeupTime = UIMonoState_timerMillisecondClock(); |
|||
} |
|||
public float deadline { |
|||
get { return _deadline; } |
|||
} |
|||
const long MILLI_TO_NANO = 1000000L; |
|||
|
|||
void _enqueue() { |
|||
Isolate.ensureExists(); |
|||
|
|||
GCHandle callbackHandle = GCHandle.Alloc(this); |
|||
UIMonoState_postTaskForTime(_postTaskForTime, (IntPtr) callbackHandle, _wakeupTime * MILLI_TO_NANO); |
|||
} |
|||
public override void cancel() { |
|||
_done = true; |
|||
} |
|||
[MonoPInvokeCallback(typeof(UIMonoState_postTaskForTimeCallback))] |
|||
static void _postTaskForTime(IntPtr callbackHandle) { |
|||
GCHandle timerHandle = (GCHandle) callbackHandle; |
|||
var timer = (_Timer) timerHandle.Target; |
|||
timerHandle.Free(); |
|||
public bool done { |
|||
get { return _done; } |
|||
} |
|||
|
|||
public void invoke() { |
|||
if (_done) { |
|||
return; |
|||
} |
|||
try { |
|||
if (timer._callback != null) { |
|||
var callback = timer._callback; |
|||
if (!timer._repeating) { |
|||
timer._callback = null; |
|||
} |
|||
else if (timer._milliSeconds > 0) { |
|||
var ms = timer._milliSeconds; |
|||
long overdue = UIMonoState_timerMillisecondClock() - timer._wakeupTime; |
|||
if (overdue > ms) { |
|||
long missedTicks = overdue / ms; |
|||
timer._wakeupTime += missedTicks * ms; |
|||
timer._tick += missedTicks; |
|||
} |
|||
} |
|||
var now = timeSinceStartup; |
|||
if (!periodic) { |
|||
_done = true; |
|||
} |
|||
timer._tick += 1; |
|||
try { |
|||
_callback(); |
|||
} |
|||
catch (Exception ex) { |
|||
D.logError("Error to execute timer callback: ", ex); |
|||
} |
|||
callback(timer); |
|||
if (periodic) { |
|||
_deadline = now + (float) _interval.TotalSeconds; |
|||
if (timer._repeating && (timer._callback != null)) { |
|||
timer._advanceWakeupTime(); |
|||
timer._enqueue(); |
|||
} |
|||
|
|||
public int CompareTo(TimerImpl other) { |
|||
return deadline.CompareTo(other.deadline); |
|||
catch (Exception ex) { |
|||
Debug.LogException(ex); |
|||
|
|||
[DllImport(NativeBindings.dllName)] |
|||
static extern long UIMonoState_timerMillisecondClock(); |
|||
|
|||
delegate void UIMonoState_postTaskForTimeCallback(IntPtr callbackHandle); |
|||
|
|||
[DllImport(NativeBindings.dllName)] |
|||
static extern void UIMonoState_postTaskForTime(UIMonoState_postTaskForTimeCallback callback, |
|||
IntPtr callbackHandle, long targetTimeNanos); |
|||
}*/ |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5f8434687aa245d9ae7f766b6109166b |
|||
timeCreated: 1545642183 |
|||
guid: 305c123a2a944eba8f2b397a962323ff |
|||
timeCreated: 1597215247 |
|
|||
fileFormatVersion: 2 |
|||
guid: 6b74179dadff469cb8ee1f7b2ff51ae7 |
|||
timeCreated: 1534227207 |
|||
guid: 0756240ed259436a82cdc6ee65831a4f |
|||
timeCreated: 1599458325 |
|
|||
fileFormatVersion: 2 |
|||
guid: 3fb425debd2a441cadf8ad4a4fed3aa1 |
|||
timeCreated: 1536717302 |
|||
guid: 9ee135f21ca64943a5f75a04a0e30cc3 |
|||
timeCreated: 1599458326 |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue