GitHub
6 年前
当前提交
b4ec4918
共有 34 个文件被更改,包括 1891 次插入 和 64 次删除
-
3Assets/UIWidgets/Tests/CanvasAndLayers.cs
-
2Assets/UIWidgets/Tests/EditableTextWiget.cs
-
2Assets/UIWidgets/Tests/Gestures.cs
-
2Assets/UIWidgets/Tests/Paragraph.cs
-
2Assets/UIWidgets/Tests/RenderBoxes.cs
-
2Assets/UIWidgets/Tests/RenderEditable.cs
-
6Assets/UIWidgets/Tests/SceneViewTests.cs
-
8Assets/UIWidgets/Tests/Widgets.cs
-
6Assets/UIWidgets/debugger/inpsector_panel.cs
-
6Assets/UIWidgets/debugger/inspector_treeview.cs
-
10Assets/UIWidgets/debugger/inspector_window.cs
-
110Assets/UIWidgets/editor/editor_window.cs
-
20Assets/UIWidgets/editor/surface.cs
-
7Assets/UIWidgets/foundation/basic_types.cs
-
1Assets/UIWidgets/painting/text_span.cs
-
3Assets/UIWidgets/ui/txt/utils.cs
-
18Assets/UIWidgets/widgets/editable_text.cs
-
2Assets/UIWidgets/widgets/sliver.cs
-
6Packages/manifest.json
-
7ProjectSettings/EditorBuildSettings.asset
-
2ProjectSettings/ProjectVersion.txt
-
2Assets/UIWidgets/widgets/automatic_keep_alive.cs
-
3Assets/UIWidgets/engine.meta
-
3Assets/UIWidgetsSample.meta
-
251Assets/UIWidgets/engine/WidgetCanvas.cs
-
3Assets/UIWidgets/engine/WidgetCanvas.cs.meta
-
7Assets/UIWidgetsSample/UIWidgetSample.unity.meta
-
199Assets/UIWidgetsSample/ToDoAppCanvas.cs
-
609Assets/UIWidgetsSample/UIWidgetSample.unity
-
653Assets/UIWidgetsSample/AsScreenCanvas.cs
-
0/Assets/UIWidgets/widgets/automatic_keep_alive.cs
-
0/Assets/UIWidgets/widgets/automatic_keep_alive.cs.meta
|
|||
m_EditorVersion: 2018.3.0a9 |
|||
m_EditorVersion: 2018.3.0b5 |
|
|||
fileFormatVersion: 2 |
|||
guid: 959505f57d724b98bb9256b0afd04e2c |
|||
timeCreated: 1545112432 |
|
|||
fileFormatVersion: 2 |
|||
guid: ade2732b79fb40cfacd288e4083d3a8e |
|||
timeCreated: 1545377495 |
|
|||
using System; |
|||
using UIWidgets.editor; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.ui; |
|||
using UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using UnityEngine.EventSystems; |
|||
using UnityEngine.UI; |
|||
using Image = UnityEngine.UI.Image; |
|||
using Rect = UnityEngine.Rect; |
|||
|
|||
namespace UIWidgets.engine |
|||
{ |
|||
public class UIWidgetWindowAdapter : WindowAdapter |
|||
{ |
|||
private WidgetCanvas _widgetCanvas; |
|||
|
|||
public UIWidgetWindowAdapter(WidgetCanvas widgetCanvas) |
|||
{ |
|||
this._widgetCanvas = widgetCanvas; |
|||
} |
|||
|
|||
protected override Surface createSurface() |
|||
{ |
|||
return new EditorWindowSurface(_widgetCanvas.applyRenderTexture); |
|||
} |
|||
|
|||
public override GUIContent titleContent |
|||
{ |
|||
get { return new GUIContent(_widgetCanvas.gameObject.name); } |
|||
} |
|||
|
|||
protected override double queryDevicePixelRatio() |
|||
{ |
|||
return _widgetCanvas.canvas.scaleFactor; |
|||
} |
|||
|
|||
protected override Vector2 queryWindowSize() |
|||
{ |
|||
return _widgetCanvas.rectTransform.rect.size; |
|||
} |
|||
} |
|||
|
|||
[RequireComponent(typeof(RectTransform))] |
|||
public abstract class WidgetCanvas : MaskableGraphic, IPointerDownHandler, IPointerUpHandler, IDragHandler, |
|||
IPointerEnterHandler, IPointerExitHandler |
|||
{ |
|||
private WindowAdapter _windowAdapter; |
|||
private PaintingBinding _paintingBinding; |
|||
private Texture _texture; |
|||
private Vector2 _lastMouseMove; |
|||
private bool _mouseEntered; |
|||
|
|||
protected override void OnEnable() |
|||
{ |
|||
base.OnEnable(); |
|||
|
|||
if (_windowAdapter == null) |
|||
{ |
|||
this._paintingBinding = new PaintingBinding(null); |
|||
_paintingBinding.initInstances(); |
|||
_windowAdapter = new UIWidgetWindowAdapter(this); |
|||
} |
|||
|
|||
_windowAdapter.OnEnable(); |
|||
var root = new WidgetsApp(null, getWidget()); |
|||
_windowAdapter.attachRootWidget(root); |
|||
|
|||
_lastMouseMove = Input.mousePosition; |
|||
} |
|||
|
|||
private void OnDisable() |
|||
{ |
|||
this._windowAdapter.OnDisable(); |
|||
base.OnDisable(); |
|||
} |
|||
|
|||
protected abstract Widget getWidget(); |
|||
|
|||
public override Texture mainTexture |
|||
{ |
|||
get { return _texture; } |
|||
} |
|||
|
|||
internal void applyRenderTexture(Rect screenRect, Texture texture, Material mat) |
|||
{ |
|||
_texture = texture; |
|||
SetMaterialDirty(); |
|||
} |
|||
|
|||
private void OnDestroy() |
|||
{ |
|||
base.OnDestroy(); |
|||
} |
|||
|
|||
private void Update() |
|||
{ |
|||
if (_mouseEntered && (_lastMouseMove.x != Input.mousePosition.x || _lastMouseMove.y != Input.mousePosition.y)) |
|||
{ |
|||
this.OnMouseOver(); |
|||
} |
|||
|
|||
_lastMouseMove = Input.mousePosition; |
|||
if (this._windowAdapter != null) |
|||
{ |
|||
this._windowAdapter.Update(); |
|||
} |
|||
} |
|||
|
|||
|
|||
private void OnGUI() |
|||
{ |
|||
if (Event.current.type == EventType.Repaint) |
|||
{ |
|||
this._windowAdapter.OnGUI(); |
|||
} |
|||
|
|||
if (Event.current.type == EventType.KeyDown || Event.current.type == EventType.KeyUp) |
|||
{ |
|||
if (this._windowAdapter != null) |
|||
{ |
|||
this._windowAdapter.OnGUI(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private void OnMouseOver() |
|||
{ |
|||
|
|||
var pos = getPointPosition(Input.mousePosition); |
|||
// Debug.Log(string.Format("mouse move {0} {1}", pos.x, pos.y));
|
|||
this._windowAdapter.PostPointerEvent(new PointerData( |
|||
timeStamp: DateTime.Now, |
|||
change: PointerChange.hover, |
|||
kind: PointerDeviceKind.mouse, |
|||
device: getMouseButtonDown(), |
|||
physicalX: pos.x, |
|||
physicalY: pos.y |
|||
)); |
|||
} |
|||
|
|||
private int getMouseButtonDown() |
|||
{ |
|||
for (int key = 0; key < 3; key++) |
|||
{ |
|||
if (Input.GetMouseButton(key)) |
|||
{ |
|||
return key; |
|||
} |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
public void OnPointerDown(PointerEventData eventData) |
|||
{ |
|||
var position = getPointPosition(eventData); |
|||
this._windowAdapter.PostPointerEvent(new PointerData( |
|||
timeStamp: DateTime.Now, |
|||
change: PointerChange.down, |
|||
kind: PointerDeviceKind.mouse, |
|||
device: (int) eventData.button, |
|||
physicalX: position.x, |
|||
physicalY: position.y |
|||
)); |
|||
} |
|||
|
|||
public void OnPointerUp(PointerEventData eventData) |
|||
{ |
|||
var position = getPointPosition(eventData); |
|||
this._windowAdapter.PostPointerEvent(new PointerData( |
|||
timeStamp: DateTime.Now, |
|||
change: PointerChange.up, |
|||
kind: PointerDeviceKind.mouse, |
|||
device: (int) eventData.button, |
|||
physicalX: position.x, |
|||
physicalY: position.y |
|||
)); |
|||
} |
|||
|
|||
public Vector2 getPointPosition(PointerEventData eventData) |
|||
{ |
|||
Vector2 localPoint; |
|||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.position, |
|||
eventData.enterEventCamera, out localPoint); |
|||
localPoint.x = localPoint.x - rectTransform.rect.min.x; |
|||
localPoint.y = rectTransform.rect.max.y - localPoint.y; |
|||
return localPoint; |
|||
} |
|||
|
|||
public Vector2 getPointPosition(Vector2 position) |
|||
{ |
|||
// Debug.Log("mouse posse " + position.x + " " + position.y);
|
|||
Vector2 localPoint; |
|||
Camera eventCamera = null; |
|||
|
|||
if (canvas.renderMode != RenderMode.ScreenSpaceCamera) |
|||
{ |
|||
eventCamera = canvas.GetComponent<GraphicRaycaster>().eventCamera; |
|||
} |
|||
|
|||
|
|||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, position, |
|||
eventCamera, out localPoint); |
|||
localPoint.x = localPoint.x - rectTransform.rect.min.x; |
|||
localPoint.y = rectTransform.rect.max.y - localPoint.y; |
|||
return localPoint; |
|||
} |
|||
|
|||
public void OnDrag(PointerEventData eventData) |
|||
{ |
|||
var position = getPointPosition(eventData); |
|||
this._windowAdapter.PostPointerEvent(new PointerData( |
|||
timeStamp: DateTime.Now, |
|||
change: PointerChange.move, |
|||
kind: PointerDeviceKind.mouse, |
|||
device: (int) eventData.button, |
|||
physicalX: position.x, |
|||
physicalY: position.y |
|||
)); |
|||
} |
|||
|
|||
public void OnPointerEnter(PointerEventData eventData) |
|||
{ |
|||
_mouseEntered = true; |
|||
_lastMouseMove = eventData.position; |
|||
var position = getPointPosition(eventData); |
|||
this._windowAdapter.PostPointerEvent(new PointerData( |
|||
timeStamp: DateTime.Now, |
|||
change: PointerChange.hover, |
|||
kind: PointerDeviceKind.mouse, |
|||
device: (int) eventData.button, |
|||
physicalX: position.x, |
|||
physicalY: position.y |
|||
)); |
|||
} |
|||
|
|||
public void OnPointerExit(PointerEventData eventData) |
|||
{ |
|||
_mouseEntered = false; |
|||
var position = getPointPosition(eventData); |
|||
this._windowAdapter.PostPointerEvent(new PointerData( |
|||
timeStamp: DateTime.Now, |
|||
change: PointerChange.hover, |
|||
kind: PointerDeviceKind.mouse, |
|||
device: (int) eventData.button, |
|||
physicalX: position.x, |
|||
physicalY: position.y |
|||
)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5f8434687aa245d9ae7f766b6109166b |
|||
timeCreated: 1545642183 |
|
|||
fileFormatVersion: 2 |
|||
guid: 4e3b67b8f19ff4635b924fb6e01a071d |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UIWidgets.engine; |
|||
using UIWidgets.foundation; |
|||
using UIWidgets.gestures; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.ui; |
|||
using UIWidgets.widgets; |
|||
using TextStyle = UIWidgets.painting.TextStyle; |
|||
|
|||
namespace UIWidgetsSample |
|||
{ |
|||
public class ToDoAppCanvas : WidgetCanvas |
|||
{ |
|||
public class ToDoListApp : StatefulWidget |
|||
{ |
|||
public ToDoListApp(Key key = null) : base(key) |
|||
{ |
|||
} |
|||
|
|||
public override State createState() |
|||
{ |
|||
return new _ToDoListAppState(); |
|||
} |
|||
} |
|||
|
|||
protected override Widget getWidget() |
|||
{ |
|||
return new ToDoListApp(); |
|||
} |
|||
|
|||
public class CustomButton : StatelessWidget |
|||
{ |
|||
public CustomButton( |
|||
Key key = null, |
|||
GestureTapCallback onPressed = null, |
|||
EdgeInsets padding = null, |
|||
Color backgroundColor = null, |
|||
Widget child = null |
|||
) : base(key: key) |
|||
{ |
|||
this.onPressed = onPressed; |
|||
this.padding = padding ?? EdgeInsets.all(8.0); |
|||
this.backgroundColor = backgroundColor ?? AsScreenCanvas.CLColors.transparent; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly GestureTapCallback onPressed; |
|||
public readonly EdgeInsets padding; |
|||
public readonly Widget child; |
|||
public readonly Color backgroundColor; |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new GestureDetector( |
|||
onTap: this.onPressed, |
|||
child: new Container( |
|||
padding: this.padding, |
|||
color: this.backgroundColor, |
|||
child: this.child |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _ToDoListAppState : State<ToDoListApp> |
|||
{ |
|||
public class ToDoItem |
|||
{ |
|||
public int id; |
|||
public string content; |
|||
} |
|||
|
|||
private List<ToDoItem> items = new List<ToDoItem>(); |
|||
private int nextId = 0; |
|||
private TextEditingController controller = new TextEditingController(""); |
|||
|
|||
private Widget title() |
|||
{ |
|||
return new Text("ToDo App", textAlign: TextAlign.center, |
|||
style: new TextStyle(fontSize:30, fontWeight: FontWeight.w700)); |
|||
} |
|||
|
|||
private Widget textInput() |
|||
{ |
|||
return new Container( |
|||
child: new Row( |
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|||
children: new List<Widget>( |
|||
) |
|||
{ |
|||
new Container( |
|||
width: 300, |
|||
decoration: new BoxDecoration(border: Border.all(new Color(0xFF000000), 1)), |
|||
padding: EdgeInsets.fromLTRB(8, 0, 8, 0), |
|||
child: new EditableText(maxLines: 1, |
|||
controller: controller, |
|||
|
|||
focusNode: new FocusNode(), |
|||
style: new TextStyle( |
|||
fontSize: 18, |
|||
height: 1.5f, |
|||
color: new Color(0xFF1389FD) |
|||
), |
|||
selectionColor: Color.fromARGB(255, 255, 0, 0), |
|||
cursorColor: Color.fromARGB(255, 0, 0, 0)) |
|||
), |
|||
|
|||
new CustomButton(backgroundColor: Color.fromARGB(255, 0, 204, 204), |
|||
padding: EdgeInsets.all(10), |
|||
child: new Text("Add", style: new TextStyle( |
|||
fontSize: 20, color: Color.fromARGB(255, 255, 255, 255), fontWeight: FontWeight.w700 |
|||
)), onPressed: () => |
|||
{ |
|||
setState(() => |
|||
{ |
|||
if (controller.text != "") |
|||
{ |
|||
items.Add(new ToDoItem() {id = nextId++, content = controller.text}); |
|||
} |
|||
}); |
|||
}) |
|||
} |
|||
) |
|||
); |
|||
} |
|||
|
|||
private Widget contents() |
|||
{ |
|||
var children = items.Select((item) => { return (Widget) new Text( |
|||
item.content, style: new TextStyle( |
|||
fontSize: 18, |
|||
height: 1.5 |
|||
) |
|||
); }); |
|||
return new Flexible( |
|||
child: new ListView( |
|||
physics: new AlwaysScrollableScrollPhysics(), |
|||
children: children.ToList() |
|||
) |
|||
); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
var container = new Container( |
|||
padding: EdgeInsets.all(10), |
|||
decoration: new BoxDecoration(color:new Color(0x7F000000), border:Border.all(color: Color.fromARGB(255, 255, 0, 0), width: 5), |
|||
borderRadius: BorderRadius.all(2)), |
|||
child: new Column( |
|||
crossAxisAlignment: CrossAxisAlignment.stretch, |
|||
children: new List<Widget> |
|||
{ |
|||
title(), |
|||
textInput(), |
|||
contents(), |
|||
} |
|||
) |
|||
); |
|||
return container; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class CustomButton : StatelessWidget |
|||
{ |
|||
public CustomButton( |
|||
Key key = null, |
|||
GestureTapCallback onPressed = null, |
|||
EdgeInsets padding = null, |
|||
Color backgroundColor = null, |
|||
Widget child = null |
|||
) : base(key: key) |
|||
{ |
|||
this.onPressed = onPressed; |
|||
this.padding = padding ?? EdgeInsets.all(8.0); |
|||
this.backgroundColor = backgroundColor ?? AsScreenCanvas.CLColors.transparent; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly GestureTapCallback onPressed; |
|||
public readonly EdgeInsets padding; |
|||
public readonly Widget child; |
|||
public readonly Color backgroundColor; |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new GestureDetector( |
|||
onTap: this.onPressed, |
|||
child: new Container( |
|||
padding: this.padding, |
|||
color: this.backgroundColor, |
|||
child: this.child |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!29 &1 |
|||
OcclusionCullingSettings: |
|||
m_ObjectHideFlags: 0 |
|||
serializedVersion: 2 |
|||
m_OcclusionBakeSettings: |
|||
smallestOccluder: 5 |
|||
smallestHole: 0.25 |
|||
backfaceThreshold: 100 |
|||
m_SceneGUID: 00000000000000000000000000000000 |
|||
m_OcclusionCullingData: {fileID: 0} |
|||
--- !u!104 &2 |
|||
RenderSettings: |
|||
m_ObjectHideFlags: 0 |
|||
serializedVersion: 9 |
|||
m_Fog: 0 |
|||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} |
|||
m_FogMode: 3 |
|||
m_FogDensity: 0.01 |
|||
m_LinearFogStart: 0 |
|||
m_LinearFogEnd: 300 |
|||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} |
|||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} |
|||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} |
|||
m_AmbientIntensity: 1 |
|||
m_AmbientMode: 0 |
|||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} |
|||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_HaloStrength: 0.5 |
|||
m_FlareStrength: 1 |
|||
m_FlareFadeSpeed: 3 |
|||
m_HaloTexture: {fileID: 0} |
|||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} |
|||
m_DefaultReflectionMode: 0 |
|||
m_DefaultReflectionResolution: 128 |
|||
m_ReflectionBounces: 1 |
|||
m_ReflectionIntensity: 1 |
|||
m_CustomReflection: {fileID: 0} |
|||
m_Sun: {fileID: 0} |
|||
m_IndirectSpecularColor: {r: 0.3731196, g: 0.38074002, b: 0.35872707, a: 1} |
|||
m_UseRadianceAmbientProbe: 0 |
|||
--- !u!157 &3 |
|||
LightmapSettings: |
|||
m_ObjectHideFlags: 0 |
|||
serializedVersion: 11 |
|||
m_GIWorkflowMode: 0 |
|||
m_GISettings: |
|||
serializedVersion: 2 |
|||
m_BounceScale: 1 |
|||
m_IndirectOutputScale: 1 |
|||
m_AlbedoBoost: 1 |
|||
m_EnvironmentLightingMode: 0 |
|||
m_EnableBakedLightmaps: 1 |
|||
m_EnableRealtimeLightmaps: 1 |
|||
m_LightmapEditorSettings: |
|||
serializedVersion: 10 |
|||
m_Resolution: 2 |
|||
m_BakeResolution: 40 |
|||
m_AtlasSize: 1024 |
|||
m_AO: 0 |
|||
m_AOMaxDistance: 1 |
|||
m_CompAOExponent: 1 |
|||
m_CompAOExponentDirect: 0 |
|||
m_Padding: 2 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_LightmapsBakeMode: 1 |
|||
m_TextureCompression: 1 |
|||
m_FinalGather: 0 |
|||
m_FinalGatherFiltering: 1 |
|||
m_FinalGatherRayCount: 256 |
|||
m_ReflectionCompression: 2 |
|||
m_MixedBakeMode: 2 |
|||
m_BakeBackend: 1 |
|||
m_PVRSampling: 1 |
|||
m_PVRDirectSampleCount: 32 |
|||
m_PVRSampleCount: 500 |
|||
m_PVRBounces: 2 |
|||
m_PVRFilterTypeDirect: 0 |
|||
m_PVRFilterTypeIndirect: 0 |
|||
m_PVRFilterTypeAO: 0 |
|||
m_PVRFilteringMode: 1 |
|||
m_PVRCulling: 1 |
|||
m_PVRFilteringGaussRadiusDirect: 1 |
|||
m_PVRFilteringGaussRadiusIndirect: 5 |
|||
m_PVRFilteringGaussRadiusAO: 2 |
|||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5 |
|||
m_PVRFilteringAtrousPositionSigmaIndirect: 2 |
|||
m_PVRFilteringAtrousPositionSigmaAO: 1 |
|||
m_ShowResolutionOverlay: 1 |
|||
m_LightingDataAsset: {fileID: 0} |
|||
m_UseShadowmask: 1 |
|||
--- !u!196 &4 |
|||
NavMeshSettings: |
|||
serializedVersion: 2 |
|||
m_ObjectHideFlags: 0 |
|||
m_BuildSettings: |
|||
serializedVersion: 2 |
|||
agentTypeID: 0 |
|||
agentRadius: 0.5 |
|||
agentHeight: 2 |
|||
agentSlope: 45 |
|||
agentClimb: 0.4 |
|||
ledgeDropHeight: 0 |
|||
maxJumpAcrossDistance: 0 |
|||
minRegionArea: 2 |
|||
manualCellSize: 0 |
|||
cellSize: 0.16666667 |
|||
manualTileSize: 0 |
|||
tileSize: 256 |
|||
accuratePlacement: 0 |
|||
debug: |
|||
m_Flags: 0 |
|||
m_NavMeshData: {fileID: 0} |
|||
--- !u!1 &244594849 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 244594852} |
|||
- component: {fileID: 244594851} |
|||
- component: {fileID: 244594850} |
|||
- component: {fileID: 244594854} |
|||
m_Layer: 0 |
|||
m_Name: Main Camera |
|||
m_TagString: MainCamera |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!81 &244594850 |
|||
AudioListener: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 244594849} |
|||
m_Enabled: 1 |
|||
--- !u!20 &244594851 |
|||
Camera: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 244594849} |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_ClearFlags: 1 |
|||
m_BackGroundColor: {r: 1, g: 1, b: 1, a: 1} |
|||
m_projectionMatrixMode: 1 |
|||
m_SensorSize: {x: 36, y: 24} |
|||
m_LensShift: {x: 0, y: 0} |
|||
m_GateFitMode: 2 |
|||
m_FocalLength: 50 |
|||
m_NormalizedViewPortRect: |
|||
serializedVersion: 2 |
|||
x: 0 |
|||
y: 0 |
|||
width: 1 |
|||
height: 1 |
|||
near clip plane: 1 |
|||
far clip plane: 100 |
|||
field of view: 26.991467 |
|||
orthographic: 0 |
|||
orthographic size: 5 |
|||
m_Depth: -1 |
|||
m_CullingMask: |
|||
serializedVersion: 2 |
|||
m_Bits: 4294967295 |
|||
m_RenderingPath: -1 |
|||
m_TargetTexture: {fileID: 0} |
|||
m_TargetDisplay: 0 |
|||
m_TargetEye: 3 |
|||
m_HDR: 1 |
|||
m_AllowMSAA: 1 |
|||
m_AllowDynamicResolution: 0 |
|||
m_ForceIntoRT: 0 |
|||
m_OcclusionCulling: 1 |
|||
m_StereoConvergence: 10 |
|||
m_StereoSeparation: 0.022 |
|||
--- !u!4 &244594852 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 244594849} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: -15} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!114 &244594854 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 244594849} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: -768656878, guid: f70555f144d8491a825f0804e09c671c, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_EventMask: |
|||
serializedVersion: 2 |
|||
m_Bits: 4294967295 |
|||
m_MaxRayIntersections: 0 |
|||
--- !u!1 &304189370 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 304189374} |
|||
- component: {fileID: 304189373} |
|||
- component: {fileID: 304189372} |
|||
- component: {fileID: 304189371} |
|||
- component: {fileID: 304189376} |
|||
m_Layer: 5 |
|||
m_Name: Canvas |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!114 &304189371 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 304189370} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_IgnoreReversedGraphics: 1 |
|||
m_BlockingObjects: 0 |
|||
m_BlockingMask: |
|||
serializedVersion: 2 |
|||
m_Bits: 4294967295 |
|||
--- !u!114 &304189372 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 304189370} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_UiScaleMode: 0 |
|||
m_ReferencePixelsPerUnit: 100 |
|||
m_ScaleFactor: 1 |
|||
m_ReferenceResolution: {x: 800, y: 600} |
|||
m_ScreenMatchMode: 0 |
|||
m_MatchWidthOrHeight: 0 |
|||
m_PhysicalUnit: 3 |
|||
m_FallbackScreenDPI: 96 |
|||
m_DefaultSpriteDPI: 96 |
|||
m_DynamicPixelsPerUnit: 1 |
|||
--- !u!223 &304189373 |
|||
Canvas: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 304189370} |
|||
m_Enabled: 1 |
|||
serializedVersion: 3 |
|||
m_RenderMode: 0 |
|||
m_Camera: {fileID: 0} |
|||
m_PlaneDistance: 100 |
|||
m_PixelPerfect: 0 |
|||
m_ReceivesEvents: 1 |
|||
m_OverrideSorting: 0 |
|||
m_OverridePixelPerfect: 0 |
|||
m_SortingBucketNormalizedSize: 0 |
|||
m_AdditionalShaderChannelsFlag: 0 |
|||
m_SortingLayerID: 0 |
|||
m_SortingOrder: 0 |
|||
m_TargetDisplay: 0 |
|||
--- !u!224 &304189374 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 304189370} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 0, y: 0, z: 0} |
|||
m_Children: |
|||
- {fileID: 1387978527} |
|||
- {fileID: 895510406} |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 2 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
m_AnchorMin: {x: 0, y: 0} |
|||
m_AnchorMax: {x: 0, y: 0} |
|||
m_AnchoredPosition: {x: 0, y: 0} |
|||
m_SizeDelta: {x: 0, y: 0} |
|||
m_Pivot: {x: 0, y: 0} |
|||
--- !u!222 &304189376 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 304189370} |
|||
m_CullTransparentMesh: 0 |
|||
--- !u!1 &390948269 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 390948272} |
|||
- component: {fileID: 390948271} |
|||
- component: {fileID: 390948270} |
|||
m_Layer: 0 |
|||
m_Name: EventSystem |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!114 &390948270 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 390948269} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_HorizontalAxis: Horizontal |
|||
m_VerticalAxis: Vertical |
|||
m_SubmitButton: Submit |
|||
m_CancelButton: Cancel |
|||
m_InputActionsPerSecond: 10 |
|||
m_RepeatDelay: 0.5 |
|||
m_ForceModuleActive: 0 |
|||
--- !u!114 &390948271 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 390948269} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_FirstSelected: {fileID: 0} |
|||
m_sendNavigationEvents: 1 |
|||
m_DragThreshold: 10 |
|||
--- !u!4 &390948272 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 390948269} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 3 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!1 &895510405 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 895510406} |
|||
- component: {fileID: 895510408} |
|||
- component: {fileID: 895510407} |
|||
m_Layer: 5 |
|||
m_Name: ASCanvas |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 0 |
|||
--- !u!224 &895510406 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 895510405} |
|||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 304189374} |
|||
m_RootOrder: 1 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
m_AnchorMin: {x: 0, y: 0} |
|||
m_AnchorMax: {x: 1, y: 1} |
|||
m_AnchoredPosition: {x: 0, y: 0} |
|||
m_SizeDelta: {x: -20, y: -20} |
|||
m_Pivot: {x: 0.5, y: 0.5} |
|||
--- !u!114 &895510407 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 895510405} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: ba89f9629cde43108c86110ad5a888b3, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_Material: {fileID: 0} |
|||
m_Color: {r: 1, g: 1, b: 1, a: 1} |
|||
m_RaycastTarget: 1 |
|||
m_OnCullStateChanged: |
|||
m_PersistentCalls: |
|||
m_Calls: [] |
|||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, |
|||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null |
|||
--- !u!222 &895510408 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 895510405} |
|||
m_CullTransparentMesh: 0 |
|||
--- !u!1 &1387978526 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 1387978527} |
|||
- component: {fileID: 1387978529} |
|||
- component: {fileID: 1387978528} |
|||
m_Layer: 5 |
|||
m_Name: ToAppCanvas |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &1387978527 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1387978526} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 304189374} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
m_AnchorMin: {x: 0, y: 0} |
|||
m_AnchorMax: {x: 1, y: 1} |
|||
m_AnchoredPosition: {x: 0, y: 0} |
|||
m_SizeDelta: {x: -400, y: -118} |
|||
m_Pivot: {x: 0.5, y: 0.5} |
|||
--- !u!114 &1387978528 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1387978526} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 45ef9c98c7594497921b0c714f2b4c33, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_Material: {fileID: 0} |
|||
m_Color: {r: 1, g: 1, b: 1, a: 1} |
|||
m_RaycastTarget: 1 |
|||
m_OnCullStateChanged: |
|||
m_PersistentCalls: |
|||
m_Calls: [] |
|||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, |
|||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null |
|||
--- !u!222 &1387978529 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1387978526} |
|||
m_CullTransparentMesh: 0 |
|||
--- !u!1 &1492232671 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 1492232675} |
|||
- component: {fileID: 1492232674} |
|||
- component: {fileID: 1492232673} |
|||
- component: {fileID: 1492232672} |
|||
m_Layer: 0 |
|||
m_Name: Cube |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 0 |
|||
--- !u!65 &1492232672 |
|||
BoxCollider: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1492232671} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 0 |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_Size: {x: 1, y: 1, z: 1} |
|||
m_Center: {x: 0, y: 0, z: 0} |
|||
--- !u!23 &1492232673 |
|||
MeshRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1492232671} |
|||
m_Enabled: 1 |
|||
m_CastShadows: 1 |
|||
m_ReceiveShadows: 1 |
|||
m_DynamicOccludee: 1 |
|||
m_MotionVectors: 1 |
|||
m_LightProbeUsage: 1 |
|||
m_ReflectionProbeUsage: 1 |
|||
m_RenderingLayerMask: 1 |
|||
m_RendererPriority: 0 |
|||
m_Materials: |
|||
- {fileID: 2100000, guid: 7e4e4512ac8a44bf09367b1661efddc4, type: 2} |
|||
m_StaticBatchInfo: |
|||
firstSubMesh: 0 |
|||
subMeshCount: 0 |
|||
m_StaticBatchRoot: {fileID: 0} |
|||
m_ProbeAnchor: {fileID: 0} |
|||
m_LightProbeVolumeOverride: {fileID: 0} |
|||
m_ScaleInLightmap: 1 |
|||
m_PreserveUVs: 0 |
|||
m_IgnoreNormalsForChartDetection: 0 |
|||
m_ImportantGI: 0 |
|||
m_StitchLightmapSeams: 0 |
|||
m_SelectedEditorRenderState: 3 |
|||
m_MinimumChartSize: 4 |
|||
m_AutoUVMaxDistance: 0.5 |
|||
m_AutoUVMaxAngle: 89 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_SortingLayerID: 0 |
|||
m_SortingLayer: 0 |
|||
m_SortingOrder: 0 |
|||
--- !u!33 &1492232674 |
|||
MeshFilter: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1492232671} |
|||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} |
|||
--- !u!4 &1492232675 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1492232671} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: -1} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 1 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|
|||
using System.Collections.Generic; |
|||
using UIWidgets.engine; |
|||
using UIWidgets.foundation; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.ui; |
|||
using UIWidgets.widgets; |
|||
using Image = UIWidgets.widgets.Image; |
|||
using TextStyle = UIWidgets.painting.TextStyle; |
|||
|
|||
namespace UIWidgetsSample |
|||
{ |
|||
public class AsScreenCanvas : WidgetCanvas |
|||
{ |
|||
protected override Widget getWidget() |
|||
{ |
|||
return new AsScreen(); |
|||
} |
|||
|
|||
public class AsScreen : StatefulWidget |
|||
{ |
|||
public AsScreen(Key key = null) : base(key) |
|||
{ |
|||
} |
|||
|
|||
public override State createState() |
|||
{ |
|||
return new _AsScreenState(); |
|||
} |
|||
} |
|||
|
|||
class _AsScreenState : State<AsScreen> |
|||
{ |
|||
const double headerHeight = 50.0; |
|||
|
|||
Widget _buildHeader(BuildContext context) |
|||
{ |
|||
return new Container( |
|||
padding: EdgeInsets.only(left: 16.0, right: 8.0), |
|||
height: headerHeight, |
|||
color: CLColors.header, |
|||
child: new Row( |
|||
mainAxisAlignment: MainAxisAlignment.center, |
|||
children: new List<Widget> |
|||
{ |
|||
new Container( |
|||
child: new Text( |
|||
"All Assets", |
|||
style: new TextStyle( |
|||
fontSize: 16, |
|||
color: Color.fromARGB(100, 255, 255, 0) |
|||
) |
|||
) |
|||
), |
|||
new CustomButton( |
|||
padding: EdgeInsets.only(0.0, 0.0, 16.0, 0.0), |
|||
child: new Icon( |
|||
Icons.keyboard_arrow_down, |
|||
size: 18.0, |
|||
color: CLColors.icon2 |
|||
) |
|||
), |
|||
new Container( |
|||
decoration: new BoxDecoration( |
|||
color: CLColors.white, |
|||
borderRadius: BorderRadius.all(3) |
|||
), |
|||
width: 320, |
|||
height: 36, |
|||
padding: EdgeInsets.all(10.0), |
|||
margin: EdgeInsets.only(right: 4), |
|||
child: new EditableText( |
|||
maxLines: 1, |
|||
controller: new TextEditingController("Type here to search assets"), |
|||
focusNode: new FocusNode(), |
|||
style: new TextStyle( |
|||
fontSize: 16 |
|||
), |
|||
selectionColor: Color.fromARGB(255, 255, 0, 0), |
|||
cursorColor: Color.fromARGB(255, 0, 0, 0) |
|||
) |
|||
), |
|||
new Container( |
|||
decoration: new BoxDecoration( |
|||
color: CLColors.background4, |
|||
borderRadius: BorderRadius.all(2) |
|||
), |
|||
width: 36, |
|||
height: 36, |
|||
child: new Row( |
|||
mainAxisAlignment: MainAxisAlignment.center, |
|||
crossAxisAlignment: CrossAxisAlignment.center, |
|||
children: new List<Widget> |
|||
{ |
|||
new CustomButton( |
|||
padding: EdgeInsets.only(8.0, 0.0, 8.0, 0.0), |
|||
child: new Icon( |
|||
Icons.search, |
|||
size: 18.0, |
|||
color: CLColors.white |
|||
) |
|||
) |
|||
} |
|||
) |
|||
), |
|||
new Container( |
|||
margin: EdgeInsets.only(left: 16, right: 16), |
|||
child: new Text( |
|||
"Learn Game Development", |
|||
style: new TextStyle( |
|||
fontSize: 12, |
|||
color: CLColors.white |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
decoration: new BoxDecoration( |
|||
border: Border.all( |
|||
color: CLColors.white |
|||
) |
|||
), |
|||
margin: EdgeInsets.only(right: 16), |
|||
padding: EdgeInsets.all(4), |
|||
child: new Row( |
|||
mainAxisAlignment: MainAxisAlignment.center, |
|||
crossAxisAlignment: CrossAxisAlignment.center, |
|||
children: new List<Widget> |
|||
{ |
|||
new Text( |
|||
"Plus/Pro", |
|||
style: new TextStyle( |
|||
fontSize: 11, |
|||
color: CLColors.white |
|||
) |
|||
) |
|||
} |
|||
) |
|||
), |
|||
new Container( |
|||
margin: EdgeInsets.only(right: 16), |
|||
child: new Text( |
|||
"Impressive New Assets", |
|||
style: new TextStyle( |
|||
fontSize: 12, |
|||
color: CLColors.white |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
child: new Text( |
|||
"Shop On Old Store", |
|||
style: new TextStyle( |
|||
fontSize: 12, |
|||
color: CLColors.white |
|||
) |
|||
) |
|||
), |
|||
} |
|||
) |
|||
); |
|||
} |
|||
|
|||
Widget _buildFooter(BuildContext context) |
|||
{ |
|||
return new Container( |
|||
color: CLColors.header, |
|||
margin: EdgeInsets.only(top: 50), |
|||
height: 90, |
|||
child: new Row( |
|||
mainAxisAlignment: MainAxisAlignment.center, |
|||
children: new List<Widget> |
|||
{ |
|||
new Container( |
|||
margin: EdgeInsets.only(right: 10), |
|||
child: new Text( |
|||
"Copyright © 2018 Unity Technologies", |
|||
style: new TextStyle( |
|||
fontSize: 12, |
|||
color: CLColors.text9 |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
margin: EdgeInsets.only(right: 10), |
|||
child: new Text( |
|||
"All prices are exclusive of tax", |
|||
style: new TextStyle( |
|||
fontSize: 12, |
|||
color: CLColors.text9 |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
margin: EdgeInsets.only(right: 10), |
|||
child: new Text( |
|||
"Terms of Service and EULA", |
|||
style: new TextStyle( |
|||
fontSize: 12, |
|||
color: CLColors.text10 |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
child: new Text( |
|||
"Cookies", |
|||
style: new TextStyle( |
|||
fontSize: 12, |
|||
color: CLColors.text10 |
|||
) |
|||
) |
|||
), |
|||
} |
|||
) |
|||
); |
|||
} |
|||
|
|||
Widget _buildBanner(BuildContext context) |
|||
{ |
|||
return new Container( |
|||
height: 450, |
|||
color: CLColors.white, |
|||
child: Image.network( |
|||
"https://d2ujflorbtfzji.cloudfront.net/banner/5c57178c-4be6-4903-953b-85125bfb7154.jpg", |
|||
fit: BoxFit.cover |
|||
) |
|||
); |
|||
} |
|||
|
|||
Widget _buildTopAssetsRow(BuildContext context, string title) |
|||
{ |
|||
var testCard = new AssetCard( |
|||
"AI Template", |
|||
"INVECTOR", |
|||
45.0, |
|||
36.0, |
|||
true, |
|||
"https://d2ujflorbtfzji.cloudfront.net/key-image/46dc65c1-f605-4ccb-97e0-3d60b28cfdfe.jpg" |
|||
); |
|||
return new Container( |
|||
margin: EdgeInsets.only(left: 98), |
|||
child: new Column( |
|||
children: new List<Widget> |
|||
{ |
|||
new Container( |
|||
child: new Container( |
|||
margin: EdgeInsets.only(top: 50, bottom: 20), |
|||
child: new Row( |
|||
crossAxisAlignment: CrossAxisAlignment.baseline, |
|||
children: new List<Widget> |
|||
{ |
|||
new Container( |
|||
child: new Text( |
|||
title, |
|||
style: new TextStyle( |
|||
fontSize: 24, |
|||
color: CLColors.black |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
margin: EdgeInsets.only(left: 15), |
|||
child: |
|||
new Text( |
|||
"See More", |
|||
style: new TextStyle( |
|||
fontSize: 16, |
|||
color: CLColors.text4 |
|||
) |
|||
) |
|||
) |
|||
}) |
|||
) |
|||
), |
|||
new Row( |
|||
children: new List<Widget> |
|||
{ |
|||
testCard, |
|||
testCard, |
|||
testCard, |
|||
testCard, |
|||
testCard, |
|||
testCard |
|||
} |
|||
) |
|||
} |
|||
)); |
|||
} |
|||
|
|||
bool _onNotification(ScrollNotification notification, BuildContext context) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
Widget _buildContentList(BuildContext context) |
|||
{ |
|||
return new NotificationListener<ScrollNotification>( |
|||
onNotification: (ScrollNotification notification) => |
|||
{ |
|||
_onNotification(notification, context); |
|||
return true; |
|||
}, |
|||
child: new Flexible( |
|||
child: new ListView( |
|||
physics: new AlwaysScrollableScrollPhysics(), |
|||
children: new List<Widget> |
|||
{ |
|||
_buildBanner(context), |
|||
_buildTopAssetsRow(context, "Recommanded For You"), |
|||
_buildTopAssetsRow(context, "Beach Day"), |
|||
_buildTopAssetsRow(context, "Top Free Packages"), |
|||
_buildTopAssetsRow(context, "Top Paid Packages"), |
|||
_buildFooter(context) |
|||
} |
|||
) |
|||
) |
|||
); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
var container = new Container( |
|||
color: CLColors.background3, |
|||
child: new Container( |
|||
color: CLColors.background3, |
|||
child: new Column( |
|||
children: new List<Widget> |
|||
{ |
|||
this._buildHeader(context), |
|||
this._buildContentList(context), |
|||
} |
|||
) |
|||
) |
|||
); |
|||
return container; |
|||
} |
|||
} |
|||
|
|||
public class AssetCard : StatelessWidget |
|||
{ |
|||
public AssetCard( |
|||
string name, |
|||
string category, |
|||
double price, |
|||
double priceDiscount, |
|||
bool showBadge, |
|||
string imageSrc |
|||
) |
|||
{ |
|||
this.name = name; |
|||
this.category = category; |
|||
this.price = price; |
|||
this.priceDiscount = priceDiscount; |
|||
this.showBadge = showBadge; |
|||
this.imageSrc = imageSrc; |
|||
} |
|||
|
|||
public string name; |
|||
public string category; |
|||
public double price; |
|||
public double priceDiscount; |
|||
public bool showBadge; |
|||
public string imageSrc; |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
var card = new Container( |
|||
margin: EdgeInsets.only(right: 45), |
|||
child: new Container( |
|||
child: new Column( |
|||
children: new List<Widget> |
|||
{ |
|||
new Container( |
|||
decoration: new BoxDecoration( |
|||
color: CLColors.white, |
|||
borderRadius: BorderRadius.only(topLeft: 3, topRight: 3) |
|||
), |
|||
width: 200, |
|||
height: 124, |
|||
child: Image.network( |
|||
this.imageSrc, |
|||
fit: BoxFit.fill |
|||
) |
|||
), |
|||
new Container( |
|||
color: CLColors.white, |
|||
width: 200, |
|||
height: 86, |
|||
padding: EdgeInsets.fromLTRB(14, 12, 14, 8), |
|||
child: new Column( |
|||
crossAxisAlignment: CrossAxisAlignment.baseline, |
|||
children: new List<Widget> |
|||
{ |
|||
new Container( |
|||
height: 18, |
|||
padding: EdgeInsets.only(top: 3), |
|||
child: |
|||
new Text( |
|||
category, |
|||
style: new TextStyle( |
|||
fontSize: 11, |
|||
color: CLColors.text5 |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
height: 20, |
|||
padding: EdgeInsets.only(top: 2), |
|||
child: |
|||
new Text( |
|||
name, |
|||
style: new TextStyle( |
|||
fontSize: 14, |
|||
color: CLColors.text6 |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
height: 22, |
|||
padding: EdgeInsets.only(top: 4), |
|||
child: new Row( |
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|||
children: new List<Widget> |
|||
{ |
|||
new Container( |
|||
child: new Row( |
|||
children: new List<Widget> |
|||
{ |
|||
new Container( |
|||
margin: EdgeInsets.only(right: 10), |
|||
child: new Text( |
|||
"$" + this.price, |
|||
style: new TextStyle( |
|||
fontSize: 14, |
|||
color: CLColors.text7, |
|||
decoration: TextDecoration.lineThrough |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
child: new Text( |
|||
"$" + this.priceDiscount, |
|||
style: new TextStyle( |
|||
fontSize: 14, |
|||
color: CLColors.text8 |
|||
) |
|||
) |
|||
) |
|||
}) |
|||
), |
|||
showBadge |
|||
? new Container( |
|||
width: 80, |
|||
height: 18, |
|||
color: CLColors.black, |
|||
child: new Row( |
|||
mainAxisAlignment: MainAxisAlignment.center, |
|||
crossAxisAlignment: CrossAxisAlignment.center, |
|||
children: new List<Widget> |
|||
{ |
|||
new Text( |
|||
"Plus/Pro", |
|||
style: new TextStyle( |
|||
fontSize: 11, |
|||
color: CLColors.white |
|||
) |
|||
) |
|||
} |
|||
) |
|||
) |
|||
: new Container() |
|||
} |
|||
) |
|||
) |
|||
} |
|||
) |
|||
) |
|||
} |
|||
) |
|||
) |
|||
); |
|||
return card; |
|||
} |
|||
} |
|||
|
|||
public class EventsWaterfallScreen : StatefulWidget |
|||
{ |
|||
public EventsWaterfallScreen(Key key = null) : base(key: key) |
|||
{ |
|||
} |
|||
|
|||
public override State createState() |
|||
{ |
|||
return new _EventsWaterfallScreenState(); |
|||
} |
|||
} |
|||
|
|||
class _EventsWaterfallScreenState : State<EventsWaterfallScreen> |
|||
{ |
|||
const double headerHeight = 80.0; |
|||
|
|||
double _offsetY = 0.0; |
|||
|
|||
Widget _buildHeader(BuildContext context) |
|||
{ |
|||
return new Container( |
|||
padding: EdgeInsets.only(left: 16.0, right: 8.0), |
|||
// color: CLColors.blue,
|
|||
height: headerHeight - _offsetY, |
|||
child: new Row( |
|||
children: new List<Widget> |
|||
{ |
|||
new Flexible( |
|||
flex: 1, |
|||
fit: FlexFit.tight, |
|||
child: new Text( |
|||
"Today", |
|||
style: new TextStyle( |
|||
fontSize: (34.0 / headerHeight) * (headerHeight - _offsetY), |
|||
color: CLColors.white |
|||
) |
|||
)), |
|||
new CustomButton( |
|||
padding: EdgeInsets.only(8.0, 0.0, 8.0, 0.0), |
|||
child: new Icon( |
|||
Icons.notifications, |
|||
size: 18.0, |
|||
color: CLColors.icon2 |
|||
) |
|||
), |
|||
new CustomButton( |
|||
padding: EdgeInsets.only(8.0, 0.0, 16.0, 0.0), |
|||
child: new Icon( |
|||
Icons.account_circle, |
|||
size: 18.0, |
|||
color: CLColors.icon2 |
|||
) |
|||
) |
|||
} |
|||
) |
|||
); |
|||
} |
|||
|
|||
bool _onNotification(ScrollNotification notification, BuildContext context) |
|||
{ |
|||
double pixels = notification.metrics.pixels; |
|||
if (pixels >= 0.0) |
|||
{ |
|||
if (pixels <= headerHeight) |
|||
{ |
|||
setState(() => { _offsetY = pixels / 2.0; }); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
if (_offsetY != 0.0) |
|||
{ |
|||
setState(() => { _offsetY = 0.0; }); |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
|
|||
Widget _buildContentList(BuildContext context) |
|||
{ |
|||
return new NotificationListener<ScrollNotification>( |
|||
onNotification: (ScrollNotification notification) => |
|||
{ |
|||
_onNotification(notification, context); |
|||
return true; |
|||
}, |
|||
child: new Flexible( |
|||
child: new Container( |
|||
// color: CLColors.green,
|
|||
child: ListView.builder( |
|||
itemCount: 20, |
|||
itemExtent: 100, |
|||
physics: new AlwaysScrollableScrollPhysics(), |
|||
itemBuilder: (BuildContext context1, int index) => |
|||
{ |
|||
return new Container( |
|||
color: Color.fromARGB(255, (index * 10) % 256, (index * 20) % 256, |
|||
(index * 30) % 256) |
|||
); |
|||
} |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
var container = new Container( |
|||
// color: CLColors.background1,
|
|||
child: new Container( |
|||
// color: CLColors.background1,
|
|||
child: new Column( |
|||
children: new List<Widget> |
|||
{ |
|||
this._buildHeader(context), |
|||
this._buildContentList(context) |
|||
} |
|||
) |
|||
) |
|||
); |
|||
return container; |
|||
} |
|||
} |
|||
|
|||
public static class Icons |
|||
{ |
|||
public static readonly IconData notifications = new IconData(0xe7f4, fontFamily: "Material Icons"); |
|||
public static readonly IconData account_circle = new IconData(0xe853, fontFamily: "Material Icons"); |
|||
public static readonly IconData search = new IconData(0xe8b6, fontFamily: "Material Icons"); |
|||
public static readonly IconData keyboard_arrow_down = new IconData(0xe313, fontFamily: "Material Icons"); |
|||
} |
|||
|
|||
public static class CLColors |
|||
{ |
|||
public static readonly Color primary = new Color(0xFFE91E63); |
|||
public static readonly Color secondary1 = new Color(0xFF00BCD4); |
|||
public static readonly Color secondary2 = new Color(0xFFF0513C); |
|||
public static readonly Color background1 = new Color(0xFF292929); |
|||
public static readonly Color background2 = new Color(0xFF383838); |
|||
public static readonly Color background3 = new Color(0xFFF5F5F5); |
|||
public static readonly Color background4 = new Color(0xFF00BCD4); |
|||
public static readonly Color icon1 = new Color(0xFFFFFFFF); |
|||
public static readonly Color icon2 = new Color(0xFFA4A4A4); |
|||
public static readonly Color text1 = new Color(0xFFFFFFFF); |
|||
public static readonly Color text2 = new Color(0xFFD8D8D8); |
|||
public static readonly Color text3 = new Color(0xFF959595); |
|||
public static readonly Color text4 = new Color(0xFF002835); |
|||
public static readonly Color text5 = new Color(0xFF9E9E9E); |
|||
public static readonly Color text6 = new Color(0xFF002835); |
|||
public static readonly Color text7 = new Color(0xFF5A5A5B); |
|||
public static readonly Color text8 = new Color(0xFF239988); |
|||
public static readonly Color text9 = new Color(0xFFB3B5B6); |
|||
public static readonly Color text10 = new Color(0xFF00BCD4); |
|||
public static readonly Color dividingLine1 = new Color(0xFF666666); |
|||
public static readonly Color dividingLine2 = new Color(0xFF404040); |
|||
|
|||
public static readonly Color transparent = new Color(0x00000000); |
|||
public static readonly Color white = new Color(0xFFFFFFFF); |
|||
public static readonly Color black = new Color(0xFF000000); |
|||
public static readonly Color red = new Color(0xFFFF0000); |
|||
public static readonly Color green = new Color(0xFF00FF00); |
|||
public static readonly Color blue = new Color(0xFF0000FF); |
|||
|
|||
public static readonly Color header = new Color(0xFF060B0C); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue