浏览代码
Merge branch 'material' into 'master'
Merge branch 'material' into 'master'
performanceoverlay layer See merge request upm-packages/ui-widgets/com.unity.uiwidgets!97/main
Shenhua Gu
6 年前
当前提交
d757df93
共有 34 个文件被更改,包括 1953 次插入 和 222 次删除
-
4Runtime/engine/UIWidgetsPanel.cs
-
14Runtime/material/app.cs
-
30Runtime/material/arc.cs
-
8Runtime/material/drawer.cs
-
5Runtime/material/drawer_header.cs
-
6Runtime/material/expansion_panel.cs
-
5Runtime/material/expansion_tile.cs
-
6Runtime/material/icon_button.cs
-
998Runtime/material/icons.cs
-
5Runtime/material/ink_highlight.cs
-
37Runtime/material/ink_ripple.cs
-
48Runtime/material/ink_splash.cs
-
12Runtime/material/material.cs
-
10Runtime/material/scrollbar.cs
-
4Runtime/material/theme.cs
-
10Runtime/material/theme_data.cs
-
7Runtime/material/tooltip.cs
-
3Runtime/rendering/binding.cs
-
33Runtime/rendering/layer.cs
-
17Runtime/ui/compositing.cs
-
3Runtime/widgets/layout_builder.cs
-
27Samples/UIWidgetSample/MaterialSample.cs
-
95Runtime/flow/performance_overlay_layer.cs
-
11Runtime/flow/performance_overlay_layer.cs.meta
-
317Runtime/material/toggleable.cs
-
11Runtime/material/toggleable.cs.meta
-
81Runtime/rendering/performance_overlay.cs
-
11Runtime/rendering/performance_overlay.cs.meta
-
98Runtime/service/performance_utils.cs
-
11Runtime/service/performance_utils.cs.meta
-
34Runtime/widgets/performance_overlay.cs
-
11Runtime/widgets/performance_overlay.cs.meta
-
11Runtime/material/utils.cs.meta
-
192Runtime/material/utils.cs
998
Runtime/material/icons.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using UnityEngine; |
|||
using Canvas = Unity.UIWidgets.ui.Canvas; |
|||
using Rect = Unity.UIWidgets.ui.Rect; |
|||
|
|||
namespace Unity.UIWidgets.flow { |
|||
public class PerformanceOverlayLayer : Layer { |
|||
public PerformanceOverlayLayer(int options) { |
|||
this._options = options; |
|||
} |
|||
|
|||
readonly int _options; |
|||
|
|||
public override void paint(PaintContext context) { |
|||
D.assert(this.needsPainting); |
|||
const int padding = 8; |
|||
const int fpsHeight = 20; |
|||
|
|||
Canvas canvas = context.canvas; |
|||
canvas.save(); |
|||
|
|||
float x = this.paintBounds.left + padding; |
|||
float y = this.paintBounds.top + padding; |
|||
float width = this.paintBounds.width - padding * 2; |
|||
float height = this.paintBounds.height; |
|||
|
|||
this._drawFPS(canvas, x, y); |
|||
|
|||
if ((this._options & (int) PerformanceOverlayOption.drawFrameCost) == 1) { |
|||
this._drawFrameCost(canvas, x, y + fpsHeight, width, height - padding - fpsHeight); |
|||
} |
|||
|
|||
canvas.restore(); |
|||
} |
|||
|
|||
|
|||
void _drawFPS(Canvas canvas, float x, float y) { |
|||
var pb = new ParagraphBuilder(new ParagraphStyle { }); |
|||
pb.addText("FPS = " + PerformanceUtils.instance.getFPS()); |
|||
var paragraph = pb.build(); |
|||
paragraph.layout(new ParagraphConstraints(width: 300)); |
|||
|
|||
canvas.drawParagraph(paragraph, new Offset(x, y)); |
|||
} |
|||
|
|||
void _drawFrameCost(Canvas canvas, float x, float y, float width, float height) { |
|||
Rect visualizationRect = Rect.fromLTWH(x, y, width, height); |
|||
|
|||
Paint paint = new Paint {color = Colors.blue}; |
|||
Paint paint2 = new Paint {color = Colors.red}; |
|||
Paint paint3 = new Paint {color = Colors.green}; |
|||
Paint paint4 = new Paint {color = Colors.white70}; |
|||
|
|||
float[] costFrames = PerformanceUtils.instance.getFrames(); |
|||
int curFrame = PerformanceUtils.instance.getCurFrame(); |
|||
|
|||
float barWidth = Mathf.Max(1, width / costFrames.Length); |
|||
float perHeight = height / 32.0f; |
|||
|
|||
canvas.drawRect(visualizationRect, paint4); |
|||
canvas.drawRect(Rect.fromLTWH(x, y + perHeight * 16.0f, width, 1), paint3); |
|||
|
|||
float cur_x = x; |
|||
Path barPath = new Path(); |
|||
|
|||
for (var i = 0; i < costFrames.Length; i++) { |
|||
if (costFrames[i] != 0) { |
|||
float curHeight = Mathf.Min(perHeight * costFrames[i], height); |
|||
Rect barRect = Rect.fromLTWH(cur_x, y + height - curHeight, barWidth, curHeight); |
|||
barPath.addRect(barRect); |
|||
} |
|||
|
|||
cur_x += barWidth; |
|||
} |
|||
|
|||
canvas.drawPath(barPath, paint); |
|||
if (curFrame >= 0 && curFrame < costFrames.Length && costFrames[curFrame] != 0) { |
|||
float curHeight = Mathf.Min(perHeight * costFrames[curFrame], height); |
|||
Rect barRect = Rect.fromLTWH(x + barWidth * curFrame, y + height - curHeight, barWidth, curHeight); |
|||
canvas.drawRect(barRect, paint2); |
|||
|
|||
var pb = new ParagraphBuilder(new ParagraphStyle { }); |
|||
pb.addText("Frame Cost: " + costFrames[curFrame] + "ms"); |
|||
var paragraph = pb.build(); |
|||
paragraph.layout(new ParagraphConstraints(width: 300)); |
|||
|
|||
canvas.drawParagraph(paragraph, new Offset(x, y + height - 12)); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8abf5cb3d8e90423fb0d2476c8dea244 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.scheduler; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class ToggleableUtils { |
|||
public static readonly TimeSpan _kToggleDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
|
|||
public static readonly Animatable<float> _kRadialReactionRadiusTween = |
|||
new FloatTween(begin: 0.0f, end: Constants.kRadialReactionRadius); |
|||
} |
|||
|
|||
public abstract class RenderToggleable : RenderConstrainedBox { |
|||
RenderToggleable( |
|||
bool? value = null, |
|||
bool tristate = false, |
|||
Color activeColor = null, |
|||
Color inactiveColor = null, |
|||
ValueChanged<bool?> onChanged = null, |
|||
BoxConstraints additionalConstraints = null, |
|||
TickerProvider vsync = null |
|||
) : base(additionalConstraints: additionalConstraints) { |
|||
D.assert(tristate || value != null); |
|||
D.assert(activeColor != null); |
|||
D.assert(inactiveColor != null); |
|||
D.assert(vsync != null); |
|||
this._value = value; |
|||
this._tristate = tristate; |
|||
this._activeColor = activeColor; |
|||
this._inactiveColor = inactiveColor; |
|||
this._onChanged = onChanged; |
|||
this._vsync = vsync; |
|||
|
|||
this._tap = new TapGestureRecognizer { |
|||
onTapDown = this._handleTapDown, |
|||
onTap = this._handleTap, |
|||
onTapUp = this._handleTapUp, |
|||
onTapCancel = this._handleTapCancel |
|||
}; |
|||
|
|||
this._positionController = new AnimationController( |
|||
duration: ToggleableUtils._kToggleDuration, |
|||
value: value == false ? 0.0f : 1.0f, |
|||
vsync: vsync); |
|||
|
|||
this._position = new CurvedAnimation( |
|||
parent: this._positionController, |
|||
curve: Curves.linear); |
|||
this._position.addListener(this.markNeedsPaint); |
|||
this._position.addStatusListener(this._handlePositionStateChanged); |
|||
|
|||
this._reactionController = new AnimationController( |
|||
duration: Constants.kRadialReactionDuration, |
|||
vsync: vsync); |
|||
|
|||
this._reaction = new CurvedAnimation( |
|||
parent: this._reactionController, |
|||
curve: Curves.fastOutSlowIn); |
|||
this._reaction.addListener(this.markNeedsPaint); |
|||
} |
|||
|
|||
protected AnimationController positionController { |
|||
get { return this._positionController; } |
|||
} |
|||
|
|||
AnimationController _positionController; |
|||
|
|||
public CurvedAnimation position { |
|||
get { return this._position; } |
|||
} |
|||
|
|||
CurvedAnimation _position; |
|||
|
|||
protected AnimationController reactionController { |
|||
get { return this._reactionController; } |
|||
} |
|||
|
|||
AnimationController _reactionController; |
|||
|
|||
Animation<float> _reaction; |
|||
|
|||
public TickerProvider vsync { |
|||
get { return this._vsync; } |
|||
set { |
|||
D.assert(value != null); |
|||
if (value == this._vsync) { |
|||
return; |
|||
} |
|||
|
|||
this._vsync = value; |
|||
this.positionController.resync(this.vsync); |
|||
this.reactionController.resync(this.vsync); |
|||
} |
|||
} |
|||
|
|||
TickerProvider _vsync; |
|||
|
|||
public bool? value { |
|||
get { return this._value; } |
|||
set { |
|||
D.assert(this.tristate || value != null); |
|||
if (value == this._value) { |
|||
return; |
|||
} |
|||
|
|||
this._value = value; |
|||
this._position.curve = Curves.easeIn; |
|||
this._position.reverseCurve = Curves.easeOut; |
|||
if (this.tristate) { |
|||
switch (this._positionController.status) { |
|||
case AnimationStatus.forward: |
|||
case AnimationStatus.completed: { |
|||
this._positionController.reverse(); |
|||
break; |
|||
} |
|||
default: { |
|||
this._positionController.forward(); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
else { |
|||
if (value == true) { |
|||
this._positionController.forward(); |
|||
} |
|||
else { |
|||
this._positionController.reverse(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
bool? _value; |
|||
|
|||
public bool tristate { |
|||
get { return this._tristate; } |
|||
set { |
|||
if (value == this._tristate) { |
|||
return; |
|||
} |
|||
|
|||
this._tristate = value; |
|||
} |
|||
} |
|||
|
|||
bool _tristate; |
|||
|
|||
public Color activeColor { |
|||
get { return this._activeColor; } |
|||
set { |
|||
D.assert(value != null); |
|||
if (value == this._activeColor) { |
|||
return; |
|||
} |
|||
|
|||
this._activeColor = value; |
|||
this.markNeedsPaint(); |
|||
} |
|||
} |
|||
|
|||
Color _activeColor; |
|||
|
|||
public Color inactiveColor { |
|||
get { return this._inactiveColor; } |
|||
set { |
|||
D.assert(value != null); |
|||
if (value == this._inactiveColor) { |
|||
return; |
|||
} |
|||
|
|||
this._inactiveColor = value; |
|||
this.markNeedsPaint(); |
|||
} |
|||
} |
|||
|
|||
Color _inactiveColor; |
|||
|
|||
public ValueChanged<bool?> onChanged { |
|||
get { return this._onChanged; } |
|||
set { |
|||
if (value == this._onChanged) { |
|||
return; |
|||
} |
|||
|
|||
bool wasInteractive = this.isInteractive; |
|||
this._onChanged = value; |
|||
if (wasInteractive != this.isInteractive) { |
|||
this.markNeedsPaint(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
ValueChanged<bool?> _onChanged; |
|||
|
|||
public bool isInteractive { |
|||
get { return this.onChanged != null; } |
|||
} |
|||
|
|||
TapGestureRecognizer _tap; |
|||
Offset _downPosition; |
|||
|
|||
public override void attach(object owner) { |
|||
base.attach(owner); |
|||
if (this.value == false) { |
|||
this._positionController.reverse(); |
|||
} |
|||
else { |
|||
this._positionController.forward(); |
|||
} |
|||
|
|||
if (this.isInteractive) { |
|||
switch (this._reactionController.status) { |
|||
case AnimationStatus.forward: { |
|||
this._reactionController.forward(); |
|||
break; |
|||
} |
|||
case AnimationStatus.reverse: { |
|||
this._reactionController.reverse(); |
|||
break; |
|||
} |
|||
case AnimationStatus.dismissed: |
|||
case AnimationStatus.completed: { |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override void detach() { |
|||
this._positionController.stop(); |
|||
this._reactionController.stop(); |
|||
base.detach(); |
|||
} |
|||
|
|||
void _handlePositionStateChanged(AnimationStatus status) { |
|||
if (this.isInteractive && !this.tristate) { |
|||
if (status == AnimationStatus.completed && this._value == false) { |
|||
this.onChanged(true); |
|||
} |
|||
else if (status == AnimationStatus.dismissed && this._value != false) { |
|||
this.onChanged(false); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void _handleTapDown(TapDownDetails details) { |
|||
if (this.isInteractive) { |
|||
this._downPosition = this.globalToLocal(details.globalPosition); |
|||
this._reactionController.forward(); |
|||
} |
|||
} |
|||
|
|||
void _handleTap() { |
|||
if (!this.isInteractive) { |
|||
return; |
|||
} |
|||
|
|||
switch (this.value) { |
|||
case false: |
|||
this.onChanged(true); |
|||
break; |
|||
case true: |
|||
this.onChanged(this.tristate ? (bool?) null : false); |
|||
break; |
|||
default: |
|||
this.onChanged(false); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void _handleTapUp(TapUpDetails details) { |
|||
this._downPosition = null; |
|||
if (this.isInteractive) { |
|||
this._reactionController.reverse(); |
|||
} |
|||
} |
|||
|
|||
void _handleTapCancel() { |
|||
this._downPosition = null; |
|||
if (this.isInteractive) { |
|||
this._reactionController.reverse(); |
|||
} |
|||
} |
|||
|
|||
protected override bool hitTestSelf(Offset position) { |
|||
return true; |
|||
} |
|||
|
|||
public override void handleEvent(PointerEvent pEvent, HitTestEntry entry) { |
|||
D.assert(this.debugHandleEvent(pEvent, entry)); |
|||
if (pEvent is PointerDownEvent && this.isInteractive) { |
|||
this._tap.addPointer((PointerDownEvent) pEvent); |
|||
} |
|||
} |
|||
|
|||
public void paintRadialReaction(Canvas canvas, Offset offset, Offset origin) { |
|||
if (!this._reaction.isDismissed) { |
|||
Paint reactionPaint = new Paint {color = this.activeColor.withAlpha(Constants.kRadialReactionAlpha)}; |
|||
Offset center = Offset.lerp(this._downPosition ?? origin, origin, this._reaction.value); |
|||
float radius = ToggleableUtils._kRadialReactionRadiusTween.evaluate(this._reaction); |
|||
canvas.drawCircle(center + offset, radius, reactionPaint); |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new FlagProperty("value", value: this.value, ifTrue: "checked", ifFalse: "unchecked", |
|||
showName: true)); |
|||
properties.add(new FlagProperty("isInteractive", value: this.isInteractive, ifTrue: "enabled", |
|||
ifFalse: "disabled", defaultValue: true)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 79635a8e998444b9ba9cbab4db395efc |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.rendering { |
|||
public enum PerformanceOverlayOption { |
|||
drawFPS, //default
|
|||
drawFrameCost |
|||
} |
|||
|
|||
|
|||
public class RenderPerformanceOverlay : RenderBox { |
|||
public RenderPerformanceOverlay( |
|||
int optionsMask = 0 |
|||
) { |
|||
this._optionMask = optionsMask; |
|||
} |
|||
|
|||
public int optionsMask { |
|||
get { return this._optionMask; } |
|||
set { |
|||
if (value == this._optionMask) { |
|||
return; |
|||
} |
|||
|
|||
this._optionMask = value; |
|||
this.markNeedsPaint(); |
|||
} |
|||
} |
|||
|
|||
int _optionMask; |
|||
|
|||
protected override bool sizedByParent { |
|||
get { return true; } |
|||
} |
|||
|
|||
protected override bool alwaysNeedsCompositing { |
|||
get { return true; } |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicWidth(float height) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
protected override float computeMaxIntrinsicWidth(float height) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
float _intrinsicHeight { |
|||
get { |
|||
const float kDefaultGraphHeight = 80.0f; |
|||
float result = 20f; |
|||
|
|||
if ((this.optionsMask | (1 << (int) PerformanceOverlayOption.drawFrameCost)) > 0) { |
|||
result += kDefaultGraphHeight; |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicHeight(float width) { |
|||
return this._intrinsicHeight; |
|||
} |
|||
|
|||
protected override float computeMaxIntrinsicHeight(float width) { |
|||
return this._intrinsicHeight; |
|||
} |
|||
|
|||
protected override void performResize() { |
|||
this.size = this.constraints.constrain(new Size(float.PositiveInfinity, this._intrinsicHeight)); |
|||
} |
|||
|
|||
public override void paint(PaintingContext context, Offset offset) { |
|||
D.assert(this.needsCompositing); |
|||
context.addLayer(new PerformanceOverlayLayer( |
|||
overlayRect: Rect.fromLTWH(offset.dx, offset.dy, this.size.width, this.size.height), |
|||
optionsMask: this.optionsMask |
|||
)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2e3164a1dd18d4b4fb226e57522bb7ca |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Diagnostics; |
|||
using Unity.UIWidgets.foundation; |
|||
|
|||
namespace Unity.UIWidgets.service { |
|||
public class PerformanceUtils { |
|||
public static PerformanceUtils instance { |
|||
get { |
|||
if (_instance != null) { |
|||
return _instance; |
|||
} |
|||
|
|||
_instance = new PerformanceUtils(); |
|||
_instance._setup(); |
|||
|
|||
return _instance; |
|||
} |
|||
} |
|||
|
|||
static PerformanceUtils _instance; |
|||
|
|||
const int FrameBufferSize = 200; |
|||
|
|||
float[] _frames; |
|||
int _curFrameId; |
|||
Stopwatch _stopwatch; |
|||
|
|||
float deltaTime = 0.0f; |
|||
|
|||
bool _enabled; |
|||
|
|||
|
|||
void _setup() { |
|||
this._frames = new float[FrameBufferSize]; |
|||
this._curFrameId = -1; |
|||
this._enabled = false; |
|||
} |
|||
|
|||
void _ensureStopWatch() { |
|||
if (this._stopwatch == null) { |
|||
this._stopwatch = new Stopwatch(); |
|||
} |
|||
} |
|||
|
|||
public void updateDeltaTime(float unscaledDeltaTime) { |
|||
this.deltaTime += (unscaledDeltaTime - this.deltaTime) * 0.1f; |
|||
} |
|||
|
|||
public float getFPS() { |
|||
return 1.0f / this.deltaTime; |
|||
} |
|||
|
|||
public void startProfile() { |
|||
if (!this._enabled) { |
|||
return; |
|||
} |
|||
|
|||
this._ensureStopWatch(); |
|||
if (this._stopwatch.IsRunning) { |
|||
D.assert(false, "Try to start the stopwatch when it is already running"); |
|||
return; |
|||
} |
|||
|
|||
this._stopwatch.Start(); |
|||
} |
|||
|
|||
public void endProfile() { |
|||
if (!this._enabled || this._stopwatch == null) { |
|||
return; |
|||
} |
|||
|
|||
if (!this._stopwatch.IsRunning) { |
|||
D.assert(false, "Try to record the stopwatch when it is already stopped"); |
|||
} |
|||
|
|||
this._stopwatch.Stop(); |
|||
float frameCost = this._stopwatch.ElapsedMilliseconds; |
|||
this._stopwatch.Reset(); |
|||
if (frameCost == 0) { |
|||
return; |
|||
} |
|||
|
|||
this._curFrameId = (this._curFrameId + 1) % FrameBufferSize; |
|||
this._frames[this._curFrameId] = frameCost; |
|||
} |
|||
|
|||
public float[] getFrames() { |
|||
if (!this._enabled) { |
|||
this._enabled = true; |
|||
} |
|||
|
|||
return this._frames; |
|||
} |
|||
|
|||
public int getCurFrame() { |
|||
return this._curFrameId; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 819a2117a730b431bb069817e3ed8cd7 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.rendering; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
public class PerformanceOverlay : LeafRenderObjectWidget { |
|||
public PerformanceOverlay( |
|||
Key key = null, |
|||
int optionsMask = 0 |
|||
) : base(key: key) { |
|||
this.optionsMask = optionsMask; |
|||
} |
|||
|
|||
public readonly int optionsMask; |
|||
|
|||
public static PerformanceOverlay allEnabled( |
|||
Key key = null |
|||
) { |
|||
return new PerformanceOverlay( |
|||
optionsMask: (1 << (int) PerformanceOverlayOption.drawFPS) | |
|||
(1 << (int) PerformanceOverlayOption.drawFrameCost) |
|||
); |
|||
} |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new RenderPerformanceOverlay( |
|||
optionsMask: this.optionsMask); |
|||
} |
|||
|
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
RenderPerformanceOverlay _renderObject = (RenderPerformanceOverlay) renderObject; |
|||
_renderObject.optionsMask = this.optionsMask; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6f53af60c4e394d96880f3b94fe34dd3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 39236c38160ee4c0e928e3658102fd71 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using UnityEngine; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public static class ThemeDataUtils { |
|||
public static readonly Color _kLightThemeHighlightColor = new Color(0x66BCBCBC); |
|||
|
|||
public static readonly Color _kLightThemeSplashColor = new Color(0x66C8C8C8); |
|||
|
|||
public static readonly Color _kDarkThemeHighlightColor = new Color(0x40CCCCCC); |
|||
|
|||
public static readonly Color _kDarkThemeSplashColor = new Color(0x40CCCCCC); |
|||
} |
|||
|
|||
public static class ThemeUtils { |
|||
public static readonly TimeSpan kThemeAnimationDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
} |
|||
|
|||
public static class MaterialConstantsUtils { |
|||
public static readonly Dictionary<MaterialType, BorderRadius> kMaterialEdges = |
|||
new Dictionary<MaterialType, BorderRadius> { |
|||
{MaterialType.canvas, null}, |
|||
{MaterialType.card, BorderRadius.circular(2.0f)}, |
|||
{MaterialType.circle, null}, |
|||
{MaterialType.button, BorderRadius.circular(2.0f)}, |
|||
{MaterialType.transparency, null} |
|||
}; |
|||
} |
|||
|
|||
public static class InkHighlightUtils { |
|||
public static readonly TimeSpan _kHighlightFadeDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
} |
|||
|
|||
public static class InkSplashUtils { |
|||
public static readonly TimeSpan _kUnconfirmedSplashDuration = new TimeSpan(0, 0, 0, 1, 0); |
|||
|
|||
public static readonly TimeSpan _kSplashFadeDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
|
|||
public const float _kSplashInitialSize = 0.0f; |
|||
|
|||
public const float _kSplashConfirmedVelocity = 1.0f; |
|||
|
|||
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell, |
|||
RectCallback rectCallback) { |
|||
if (rectCallback != null) { |
|||
D.assert(containedInkWell); |
|||
return rectCallback; |
|||
} |
|||
|
|||
if (containedInkWell) { |
|||
return () => Offset.zero & referenceBox.size; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
public static float _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback, |
|||
Offset position) { |
|||
if (containedInkWell) { |
|||
Size size = rectCallback != null ? rectCallback().size : referenceBox.size; |
|||
return _getSplashRadiusForPositionInSize(size, position); |
|||
} |
|||
|
|||
return Material.defaultSplashRadius; |
|||
} |
|||
|
|||
static float _getSplashRadiusForPositionInSize(Size bounds, Offset position) { |
|||
float d1 = (position - bounds.topLeft(Offset.zero)).distance; |
|||
float d2 = (position - bounds.topRight(Offset.zero)).distance; |
|||
float d3 = (position - bounds.bottomLeft(Offset.zero)).distance; |
|||
float d4 = (position - bounds.bottomRight(Offset.zero)).distance; |
|||
return Mathf.Max(Mathf.Max(d1, d2), Mathf.Max(d3, d4)).ceil(); |
|||
} |
|||
} |
|||
|
|||
public static class InkRippleUtils { |
|||
public static readonly TimeSpan _kUnconfirmedRippleDuration = new TimeSpan(0, 0, 1); |
|||
public static readonly TimeSpan _kFadeInDuration = new TimeSpan(0, 0, 0, 0, 75); |
|||
public static readonly TimeSpan _kRadiusDuration = new TimeSpan(0, 0, 0, 0, 225); |
|||
public static readonly TimeSpan _kFadeOutDuration = new TimeSpan(0, 0, 0, 0, 375); |
|||
public static readonly TimeSpan _kCancelDuration = new TimeSpan(0, 0, 0, 0, 75); |
|||
|
|||
public const float _kFadeOutIntervalStart = 225.0f / 375.0f; |
|||
|
|||
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell, |
|||
RectCallback rectCallback) { |
|||
if (rectCallback != null) { |
|||
D.assert(containedInkWell); |
|||
return rectCallback; |
|||
} |
|||
|
|||
if (containedInkWell) { |
|||
return () => Offset.zero & referenceBox.size; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
public static float _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback, |
|||
Offset position) { |
|||
Size size = rectCallback != null ? rectCallback().size : referenceBox.size; |
|||
float d1 = size.bottomRight(Offset.zero).distance; |
|||
float d2 = (size.topRight(Offset.zero) - size.bottomLeft(Offset.zero)).distance; |
|||
return (Mathf.Max(d1, d2) / 2.0f); |
|||
} |
|||
} |
|||
|
|||
public static class ScrollbarUtils { |
|||
public static readonly TimeSpan _kScrollbarFadeDuration = TimeSpan.FromMilliseconds(300); |
|||
|
|||
public static readonly TimeSpan _kScrollbarTimeToFade = TimeSpan.FromMilliseconds(600); |
|||
|
|||
public const float _kScrollbarThickness = 6.0f; |
|||
} |
|||
|
|||
|
|||
public static class ArcUtils { |
|||
public const float _kOnAxisDelta = 2.0f; |
|||
|
|||
public static readonly List<_Diagonal> _allDiagonals = new List<_Diagonal> { |
|||
new _Diagonal(_CornerId.topLeft, _CornerId.bottomRight), |
|||
new _Diagonal(_CornerId.bottomRight, _CornerId.topLeft), |
|||
new _Diagonal(_CornerId.topRight, _CornerId.bottomLeft), |
|||
new _Diagonal(_CornerId.bottomLeft, _CornerId.topRight) |
|||
}; |
|||
|
|||
public delegate float _KeyFunc<T>(T input); |
|||
|
|||
|
|||
public static T _maxBy<T>(List<T> input, _KeyFunc<T> keyFunc) { |
|||
T maxValue = default(T); |
|||
float? maxKey = null; |
|||
foreach (T value in input) { |
|||
float key = keyFunc(value); |
|||
if (maxKey == null || key > maxKey) { |
|||
maxValue = value; |
|||
maxKey = key; |
|||
} |
|||
} |
|||
|
|||
return maxValue; |
|||
} |
|||
} |
|||
|
|||
public static class ExpansionTileUtils { |
|||
public static readonly TimeSpan _kExpand = new TimeSpan(0, 0, 0, 0, 200); |
|||
} |
|||
|
|||
public static class ExpansionPanelUtils { |
|||
public const float _kPanelHeaderCollapsedHeight = 48.0f; |
|||
public const float _kPanelHeaderExpandedHeight = 64.0f; |
|||
} |
|||
|
|||
public static class IconButtonUtils { |
|||
public const float _kMinButtonSize = 48.0f; |
|||
} |
|||
|
|||
public static class DrawerHeaderUtils { |
|||
public const float _kDrawerHeaderHeight = 160.0f + 1.0f; |
|||
} |
|||
|
|||
public static class DrawerUtils { |
|||
public const float _kWidth = 304.0f; |
|||
public const float _kEdgeDragWidth = 20.0f; |
|||
public const float _kMinFlingVelocity = 365.0f; |
|||
public static readonly TimeSpan _kBaseSettleDuration = new TimeSpan(0, 0, 0, 0, 246); |
|||
} |
|||
|
|||
public static class TooltipUtils { |
|||
public static readonly TimeSpan _kFadeDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
public static readonly TimeSpan _kShowDuration = new TimeSpan(0, 0, 0, 0, 1500); |
|||
} |
|||
|
|||
public static class AppUtils { |
|||
public static readonly TextStyle _errorTextStyle = new TextStyle( |
|||
color: new Color(0xD0FF0000), |
|||
fontFamily: "monospace", |
|||
fontSize: 48.0f, |
|||
fontWeight: FontWeight.w700, |
|||
decoration: TextDecoration.underline, |
|||
decorationColor: new Color(0xFFFFFF00), |
|||
decorationStyle: TextDecorationStyle.doubleLine |
|||
); |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue