浏览代码
Merge branches 'kgdev' and 'master' of gitlab.cds.internal.unity3d.com:upm-packages/ui-widgets/com.unity.uiwidgets into kgdev
/main
Merge branches 'kgdev' and 'master' of gitlab.cds.internal.unity3d.com:upm-packages/ui-widgets/com.unity.uiwidgets into kgdev
/main
kg
6 年前
当前提交
7d8a57f1
共有 44 个文件被更改,包括 1651 次插入 和 578 次删除
-
22README.md
-
1Runtime/editor/editor_window.cs
-
2Runtime/painting/text_painter.cs
-
41Runtime/painting/text_span.cs
-
25Runtime/painting/text_style.cs
-
490Runtime/rendering/editable.cs
-
13Runtime/rendering/paragraph.cs
-
8Runtime/rendering/viewport.cs
-
9Runtime/rendering/viewport_offset.cs
-
26Runtime/service/keyboard.cs
-
52Runtime/service/text_input.cs
-
2Runtime/ui/painting/canvas_impl.cs
-
6Runtime/ui/painting/shadow_utils.cs
-
102Runtime/ui/painting/txt/font_manager.cs
-
2Runtime/ui/painting/txt/mesh_generator.cs
-
111Runtime/ui/text.cs
-
2Runtime/ui/txt/layout.cs
-
1Runtime/ui/txt/linebreaker.cs
-
9Runtime/ui/txt/paragraph.cs
-
6Runtime/ui/txt/paragraph_builder.cs
-
11Runtime/widgets/basic.cs
-
228Runtime/widgets/editable_text.cs
-
8Runtime/widgets/scroll_position.cs
-
6Samples/UIWidgetSample/MaterialSample.cs
-
10Samples/UIWidgetsGallery/GalleryMain.cs
-
6Tests/Editor/Widgets.cs
-
24Third Party Notices.md
-
82Runtime/service/raw_keyboard.cs
-
11Runtime/service/raw_keyboard.cs.meta
-
11Runtime/ui/painting/shadow_utils.cs.meta
-
8Samples/UIWidgetSample/txt.meta
-
8Samples/UIWidgetsTheatre.meta
-
11Samples/UIWidgetSample/txt/FontWeightStyle.cs.meta
-
68Samples/UIWidgetSample/txt/TextSpanGesture.cs
-
11Samples/UIWidgetSample/txt/TextSpanGesture.cs.meta
-
85Samples/UIWidgetSample/txt/FontWeightStyle.cs
-
61Samples/UIWidgetsTheatre/UIWidgetsTheatre.cs
-
11Samples/UIWidgetsTheatre/UIWidgetsTheatre.cs.meta
-
468Samples/UIWidgetsTheatre/UIWidgetsTheatre.unity
-
7Samples/UIWidgetsTheatre/UIWidgetsTheatre.unity.meta
-
11Runtime/service/text_input_utils.cs.meta
-
153Runtime/service/text_input_utils.cs
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.service { |
|||
|
|||
public class RawKeyboard { |
|||
public static readonly RawKeyboard instance = new RawKeyboard(); |
|||
|
|||
RawKeyboard() { |
|||
|
|||
} |
|||
|
|||
readonly List<ValueChanged<RawKeyEvent>> _listeners = new List<ValueChanged<RawKeyEvent>>(); |
|||
|
|||
public void addListener(ValueChanged<RawKeyEvent> listener) { |
|||
this._listeners.Add(listener); |
|||
} |
|||
|
|||
public void removeListener(ValueChanged<RawKeyEvent> listener) { |
|||
this._listeners.Remove(listener); |
|||
} |
|||
|
|||
internal void _handleKeyEvent(Event evt) { |
|||
if (this._listeners.isEmpty()) { |
|||
return; |
|||
} |
|||
|
|||
var keyboardEvent = RawKeyEvent.fromEvent(evt); |
|||
if (keyboardEvent == null) { |
|||
return; |
|||
} |
|||
|
|||
foreach (var listener in new List<ValueChanged<RawKeyEvent>>(this._listeners)) { |
|||
if (this._listeners.Contains(listener)) { |
|||
listener(keyboardEvent); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public abstract class RawKeyEvent { |
|||
|
|||
protected RawKeyEvent(RawKeyEventData data) { |
|||
this.data = data; |
|||
} |
|||
|
|||
public static RawKeyEvent fromEvent(Event evt) { |
|||
if (evt == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (evt.type == EventType.KeyDown) { |
|||
return new RawKeyDownEvent(new RawKeyEventData(evt)); |
|||
} else if (evt.type == EventType.KeyUp) { |
|||
return new RawKeyUpEvent(new RawKeyEventData(evt)); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
public readonly RawKeyEventData data; |
|||
} |
|||
|
|||
public class RawKeyDownEvent: RawKeyEvent { |
|||
public RawKeyDownEvent(RawKeyEventData data) : base(data) { |
|||
} |
|||
} |
|||
|
|||
public class RawKeyUpEvent : RawKeyEvent { |
|||
public RawKeyUpEvent(RawKeyEventData data) : base(data) { |
|||
} |
|||
} |
|||
|
|||
public class RawKeyEventData { |
|||
public readonly Event unityEvent; |
|||
|
|||
public RawKeyEventData(Event unityEvent) { |
|||
this.unityEvent = unityEvent; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fc9a7ef33f48340668115ce929a615fc |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 338c221d7146d4ac3b3a21c2f7474fee |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 57dc3a2ca4c5643b482cd6c4e9e545d6 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b54f053c2c5d34691b30237abaf17e14 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b64f268a7786741718163d1a4eef0a8c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class TextSpanGesture : UIWidgetsSamplePanel { |
|||
protected override Widget createWidget() { |
|||
return new WidgetsApp( |
|||
home: new BuzzingText(), |
|||
pageRouteBuilder: this.pageRouteBuilder); |
|||
} |
|||
} |
|||
|
|||
class BuzzingText : StatefulWidget { |
|||
public override State createState() { |
|||
return new _BuzzingTextState(); |
|||
} |
|||
} |
|||
|
|||
class _BuzzingTextState : State<BuzzingText> { |
|||
LongPressGestureRecognizer _longPressRecognizer; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
this._longPressRecognizer = new LongPressGestureRecognizer(); |
|||
this._longPressRecognizer.onLongPress = this._handlePress; |
|||
} |
|||
|
|||
public override void dispose() { |
|||
this._longPressRecognizer.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _handlePress() { |
|||
Debug.Log("Long Pressed Text"); |
|||
} |
|||
/* |
|||
|
|||
Any professional looking app you have seen probably has multiple screens in it. It can contain a welcome screen, a login screen and then further screens. |
|||
*/ |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new RichText( |
|||
text: new TextSpan( |
|||
text: "Can you ", |
|||
style: new TextStyle(color: Colors.black), |
|||
children: new List<TextSpan>() { |
|||
new TextSpan( |
|||
text: "find the", |
|||
style: new TextStyle( |
|||
color: Colors.green, |
|||
decoration: TextDecoration.underline |
|||
) |
|||
// recognizer: this._longPressRecognizer
|
|||
), |
|||
new TextSpan( |
|||
text: " secret?" |
|||
) |
|||
} |
|||
)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c91c5cfdde64e465e956815f92b78ae7 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using FontStyle = Unity.UIWidgets.ui.FontStyle; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class FontWeightStyle : UIWidgetsSamplePanel { |
|||
protected override void Awake() { |
|||
base.Awake(); |
|||
// To run this sample, you need to download Roboto fonts and place them under Resources/Fonts folder
|
|||
// Roboto fonts could be downloaded from google website
|
|||
// https://fonts.google.com/specimen/Roboto?selection.family=Roboto
|
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "MaterialIcons-Regular"), "Material Icons"); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-Black"), "Roboto", |
|||
FontWeight.w900); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-BlackItalic"), "Roboto", |
|||
FontWeight.w900, FontStyle.italic); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-Bold"), "Roboto", |
|||
FontWeight.bold); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-BoldItalic"), "Roboto", |
|||
FontWeight.bold, FontStyle.italic); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-Regular"), "Roboto", |
|||
FontWeight.normal); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-Italic"), "Roboto", |
|||
FontWeight.normal, FontStyle.italic); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-Medium"), "Roboto", |
|||
FontWeight.w500); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-MediumItalic"), "Roboto", |
|||
FontWeight.w500, FontStyle.italic); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-Light"), "Roboto", |
|||
FontWeight.w300); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-LightItalic"), "Roboto", |
|||
FontWeight.w300, FontStyle.italic); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-Thin"), "Roboto", |
|||
FontWeight.w100); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "Fonts/Roboto-ThinItalic"), "Roboto", |
|||
FontWeight.w100, FontStyle.italic); |
|||
} |
|||
|
|||
protected override Widget createWidget() { |
|||
return new MaterialApp( |
|||
title: "Navigation Basics", |
|||
home: new FontWeightStyleWidget() |
|||
); |
|||
} |
|||
} |
|||
|
|||
class FontWeightStyleWidget : StatelessWidget { |
|||
public override Widget build(BuildContext context) { |
|||
var fontStyleTexts = new List<Widget> { |
|||
new Text("Thin", style: new TextStyle(fontWeight: FontWeight.w100)), |
|||
new Text("Thin Italic", style: new TextStyle(fontWeight: FontWeight.w100, |
|||
fontStyle: FontStyle.italic)), |
|||
new Text("Light", style: new TextStyle(fontWeight: FontWeight.w300)), |
|||
new Text("Light Italic", style: new TextStyle(fontWeight: FontWeight.w300, |
|||
fontStyle: FontStyle.italic)), |
|||
new Text("Regular", style: new TextStyle(fontWeight: FontWeight.normal)), |
|||
new Text("Regular Italic", style: new TextStyle(fontWeight: FontWeight.normal, |
|||
fontStyle: FontStyle.italic)), |
|||
new Text("Medium", style: new TextStyle(fontWeight: FontWeight.w500)), |
|||
new Text("Medium Italic", style: new TextStyle(fontWeight: FontWeight.w500, |
|||
fontStyle: FontStyle.italic)), |
|||
new Text("Bold", style: new TextStyle(fontWeight: FontWeight.bold)), |
|||
new Text("Bold Italic", style: new TextStyle(fontWeight: FontWeight.bold, |
|||
fontStyle: FontStyle.italic)), |
|||
new Text("Black", style: new TextStyle(fontWeight: FontWeight.w900)), |
|||
new Text("Black Italic", style: new TextStyle(fontWeight: FontWeight.w900, |
|||
fontStyle: FontStyle.italic)), |
|||
}; |
|||
return new Scaffold( |
|||
appBar: new AppBar( |
|||
title: new Text("Font weight & style") |
|||
), |
|||
body: new Card( |
|||
child: new DefaultTextStyle( |
|||
style: new TextStyle(fontSize: 40, fontFamily: "Roboto"), |
|||
child: new ListView(children: fontStyleTexts)) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEditor; |
|||
using UnityEditor.UI; |
|||
using UnityEngine; |
|||
|
|||
|
|||
namespace UIWidgetsSample { |
|||
|
|||
class TheatreEntry { |
|||
public string entryName; |
|||
public Widget entryWidget; |
|||
} |
|||
|
|||
class UIWidgetsTheatre : UIWidgetsSamplePanel { |
|||
static readonly List<TheatreEntry> entries = new List<TheatreEntry> { |
|||
new TheatreEntry{entryName = "Material App Bar", entryWidget = new MaterialAppBarWidget()}, |
|||
new TheatreEntry{entryName = "Material Tab Bar" , entryWidget = new MaterialTabBarWidget()} |
|||
}; |
|||
|
|||
public static string[] entryKeys { |
|||
get { |
|||
List<string> ret = new List<string>(); |
|||
foreach (var entry in entries) { |
|||
ret.Add(entry.entryName); |
|||
} |
|||
|
|||
return ret.ToArray(); |
|||
} |
|||
} |
|||
|
|||
[SerializeField] public int testCaseId; |
|||
|
|||
protected override Widget createWidget() { |
|||
return new MaterialApp( |
|||
showPerformanceOverlay: false, |
|||
home: entries[this.testCaseId].entryWidget); |
|||
} |
|||
|
|||
protected override void OnEnable() { |
|||
base.OnEnable(); |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "MaterialIcons-Regular")); |
|||
} |
|||
} |
|||
|
|||
|
|||
[CustomEditor(typeof(UIWidgetsTheatre), true)] |
|||
[CanEditMultipleObjects] |
|||
public class UIWidgetTheatreEditor : RawImageEditor { |
|||
int _choiceIndex; |
|||
|
|||
public override void OnInspectorGUI() { |
|||
var materialSample = this.target as UIWidgetsTheatre; |
|||
this._choiceIndex = EditorGUILayout.Popup("Test Case", materialSample.testCaseId, UIWidgetsTheatre.entryKeys); |
|||
materialSample.testCaseId = this._choiceIndex; |
|||
EditorUtility.SetDirty(this.target); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3ace0d3c7f55946559f1497f0fbf6025 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%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.44657898, g: 0.49641287, b: 0.5748173, 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 &314914769 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 314914773} |
|||
- component: {fileID: 314914772} |
|||
- component: {fileID: 314914771} |
|||
- component: {fileID: 314914770} |
|||
- component: {fileID: 314914775} |
|||
- component: {fileID: 314914774} |
|||
m_Layer: 5 |
|||
m_Name: Canvas |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!114 &314914770 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 314914769} |
|||
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 &314914771 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 314914769} |
|||
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 &314914772 |
|||
Canvas: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 314914769} |
|||
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 &314914773 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 314914769} |
|||
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: [] |
|||
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!114 &314914774 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 314914769} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 3ace0d3c7f55946559f1497f0fbf6025, 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 |
|||
m_Texture: {fileID: 0} |
|||
m_UVRect: |
|||
serializedVersion: 2 |
|||
x: 0 |
|||
y: 0 |
|||
width: 1 |
|||
height: 1 |
|||
devicePixelRatioOverride: 0 |
|||
testCaseId: 0 |
|||
--- !u!222 &314914775 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 314914769} |
|||
m_CullTransparentMesh: 0 |
|||
--- !u!1 &1040325770 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 1040325773} |
|||
- component: {fileID: 1040325772} |
|||
- component: {fileID: 1040325771} |
|||
m_Layer: 0 |
|||
m_Name: EventSystem |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!114 &1040325771 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1040325770} |
|||
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 &1040325772 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1040325770} |
|||
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 &1040325773 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1040325770} |
|||
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 &1125362302 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 1125362304} |
|||
- component: {fileID: 1125362303} |
|||
m_Layer: 0 |
|||
m_Name: Directional Light |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!108 &1125362303 |
|||
Light: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1125362302} |
|||
m_Enabled: 1 |
|||
serializedVersion: 8 |
|||
m_Type: 1 |
|||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} |
|||
m_Intensity: 1 |
|||
m_Range: 10 |
|||
m_SpotAngle: 30 |
|||
m_CookieSize: 10 |
|||
m_Shadows: |
|||
m_Type: 2 |
|||
m_Resolution: -1 |
|||
m_CustomResolution: -1 |
|||
m_Strength: 1 |
|||
m_Bias: 0.05 |
|||
m_NormalBias: 0.4 |
|||
m_NearPlane: 0.2 |
|||
m_Cookie: {fileID: 0} |
|||
m_DrawHalo: 0 |
|||
m_Flare: {fileID: 0} |
|||
m_RenderMode: 0 |
|||
m_CullingMask: |
|||
serializedVersion: 2 |
|||
m_Bits: 4294967295 |
|||
m_Lightmapping: 4 |
|||
m_LightShadowCasterMode: 0 |
|||
m_AreaSize: {x: 1, y: 1} |
|||
m_BounceIntensity: 1 |
|||
m_ColorTemperature: 6570 |
|||
m_UseColorTemperature: 0 |
|||
m_ShadowRadius: 0 |
|||
m_ShadowAngle: 0 |
|||
--- !u!4 &1125362304 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1125362302} |
|||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} |
|||
m_LocalPosition: {x: 0, y: 3, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 1 |
|||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} |
|||
--- !u!1 &1814350050 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 1814350053} |
|||
- component: {fileID: 1814350052} |
|||
- component: {fileID: 1814350051} |
|||
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 &1814350051 |
|||
AudioListener: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1814350050} |
|||
m_Enabled: 1 |
|||
--- !u!20 &1814350052 |
|||
Camera: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1814350050} |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_ClearFlags: 1 |
|||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} |
|||
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: 0.3 |
|||
far clip plane: 1000 |
|||
field of view: 60 |
|||
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 &1814350053 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1814350050} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 1, z: -10} |
|||
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} |
|
|||
fileFormatVersion: 2 |
|||
guid: 98c373eb224884f5f9606a9eefe03de7 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2288dc63570aa4d8db1bd6673b12634f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.service { |
|||
static partial class TextInputUtils { |
|||
static Dictionary<Event, TextInputAction> _keyToOperations; |
|||
|
|||
public static TextInputAction? getInputAction(Event evt) { |
|||
if (_keyToOperations == null) { |
|||
initKeyToOperations(); |
|||
} |
|||
|
|||
EventModifiers m = evt.modifiers; |
|||
evt.modifiers &= ~EventModifiers.CapsLock; |
|||
TextInputAction result; |
|||
var exists = _keyToOperations.TryGetValue(evt, out result); |
|||
evt.modifiers = m; |
|||
if (exists) { |
|||
return result; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
public static void initKeyToOperations() { |
|||
if (_keyToOperations != null) { |
|||
return; |
|||
} |
|||
|
|||
_keyToOperations = new Dictionary<Event, TextInputAction>(); |
|||
|
|||
// key mappings shared by the platforms
|
|||
mapKey("return", TextInputAction.newline); |
|||
mapKey("left", TextInputAction.moveLeft); |
|||
mapKey("right", TextInputAction.moveRight); |
|||
mapKey("up", TextInputAction.moveUp); |
|||
mapKey("down", TextInputAction.moveDown); |
|||
|
|||
mapKey("#left", TextInputAction.selectLeft); |
|||
mapKey("#right", TextInputAction.selectRight); |
|||
mapKey("#up", TextInputAction.selectUp); |
|||
mapKey("#down", TextInputAction.selectDown); |
|||
|
|||
mapKey("delete", TextInputAction.delete); |
|||
mapKey("backspace", TextInputAction.backspace); |
|||
mapKey("#backspace", TextInputAction.backspace); |
|||
|
|||
// OSX is the special case for input shortcuts
|
|||
if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX) { |
|||
// Keyboard mappings for mac
|
|||
// TODO mapKey ("home", TextInputAction.scrollStart);
|
|||
// TODO mapKey ("end", TextInputAction.scrollEnd);
|
|||
// TODO mapKey ("page up", TextInputAction.scrollPageUp);
|
|||
// TODO mapKey ("page down", TextInputAction.scrollPageDown);
|
|||
|
|||
mapKey("^left", TextInputAction.moveGraphicalLineStart); |
|||
mapKey("^right", TextInputAction.moveGraphicalLineEnd); |
|||
// TODO mapKey ("^up", TextInputAction.scrollPageUp);
|
|||
// TODO mapKey ("^down", TextInputAction.scrollPageDown);
|
|||
|
|||
mapKey("&left", TextInputAction.moveWordLeft); |
|||
mapKey("&right", TextInputAction.moveWordRight); |
|||
mapKey("&up", TextInputAction.moveParagraphBackward); |
|||
mapKey("&down", TextInputAction.moveParagraphForward); |
|||
|
|||
mapKey("%left", TextInputAction.moveGraphicalLineStart); |
|||
mapKey("%right", TextInputAction.moveGraphicalLineEnd); |
|||
mapKey("%up", TextInputAction.moveTextStart); |
|||
mapKey("%down", TextInputAction.moveTextEnd); |
|||
|
|||
mapKey("#home", TextInputAction.selectTextStart); |
|||
mapKey("#end", TextInputAction.selectTextEnd); |
|||
// TODO mapKey ("#page up", TextInputAction.selectPageUp);
|
|||
// TODO mapKey ("#page down", TextInputAction.selectPageDown);
|
|||
|
|||
mapKey("#^left", TextInputAction.expandSelectGraphicalLineStart); |
|||
mapKey("#^right", TextInputAction.expandSelectGraphicalLineEnd); |
|||
mapKey("#^up", TextInputAction.selectParagraphBackward); |
|||
mapKey("#^down", TextInputAction.selectParagraphForward); |
|||
|
|||
mapKey("#&left", TextInputAction.selectWordLeft); |
|||
mapKey("#&right", TextInputAction.selectWordRight); |
|||
mapKey("#&up", TextInputAction.selectParagraphBackward); |
|||
mapKey("#&down", TextInputAction.selectParagraphForward); |
|||
|
|||
mapKey("#%left", TextInputAction.expandSelectGraphicalLineStart); |
|||
mapKey("#%right", TextInputAction.expandSelectGraphicalLineEnd); |
|||
mapKey("#%up", TextInputAction.selectTextStart); |
|||
mapKey("#%down", TextInputAction.selectTextEnd); |
|||
|
|||
mapKey("%a", TextInputAction.selectAll); |
|||
mapKey("%x", TextInputAction.cut); |
|||
mapKey("%c", TextInputAction.copy); |
|||
mapKey("%v", TextInputAction.paste); |
|||
|
|||
// emacs-like keybindings
|
|||
mapKey("^d", TextInputAction.delete); |
|||
mapKey("^h", TextInputAction.backspace); |
|||
mapKey("^b", TextInputAction.moveLeft); |
|||
mapKey("^f", TextInputAction.moveRight); |
|||
mapKey("^a", TextInputAction.moveLineStart); |
|||
mapKey("^e", TextInputAction.moveLineEnd); |
|||
|
|||
mapKey("&delete", TextInputAction.deleteWordForward); |
|||
mapKey("&backspace", TextInputAction.deleteWordBack); |
|||
mapKey("%backspace", TextInputAction.deleteLineBack); |
|||
} |
|||
else { |
|||
// Windows/Linux keymappings
|
|||
mapKey("home", TextInputAction.moveGraphicalLineStart); |
|||
mapKey("end", TextInputAction.moveGraphicalLineEnd); |
|||
// TODO mapKey ("page up", TextInputAction.movePageUp);
|
|||
// TODO mapKey ("page down", TextInputAction.movePageDown);
|
|||
|
|||
mapKey("%left", TextInputAction.moveWordLeft); |
|||
mapKey("%right", TextInputAction.moveWordRight); |
|||
mapKey("%up", TextInputAction.moveParagraphBackward); |
|||
mapKey("%down", TextInputAction.moveParagraphForward); |
|||
|
|||
mapKey("^left", TextInputAction.moveToEndOfPreviousWord); |
|||
mapKey("^right", TextInputAction.moveToStartOfNextWord); |
|||
mapKey("^up", TextInputAction.moveParagraphBackward); |
|||
mapKey("^down", TextInputAction.moveParagraphForward); |
|||
|
|||
mapKey("#^left", TextInputAction.selectToEndOfPreviousWord); |
|||
mapKey("#^right", TextInputAction.selectToStartOfNextWord); |
|||
mapKey("#^up", TextInputAction.selectParagraphBackward); |
|||
mapKey("#^down", TextInputAction.selectParagraphForward); |
|||
|
|||
mapKey("#home", TextInputAction.selectGraphicalLineStart); |
|||
mapKey("#end", TextInputAction.selectGraphicalLineEnd); |
|||
// TODO mapKey ("#page up", TextInputAction.selectPageUp);
|
|||
// TODO mapKey ("#page down", TextInputAction.selectPageDown);
|
|||
|
|||
mapKey("^delete", TextInputAction.deleteWordForward); |
|||
mapKey("^backspace", TextInputAction.deleteWordBack); |
|||
mapKey("%backspace", TextInputAction.deleteLineBack); |
|||
|
|||
mapKey("^a", TextInputAction.selectAll); |
|||
mapKey("^x", TextInputAction.cut); |
|||
mapKey("^c", TextInputAction.copy); |
|||
mapKey("^v", TextInputAction.paste); |
|||
mapKey("#delete", TextInputAction.cut); |
|||
mapKey("^insert", TextInputAction.copy); |
|||
mapKey("#insert", TextInputAction.paste); |
|||
} |
|||
} |
|||
|
|||
static void mapKey(string key, TextInputAction action) { |
|||
_keyToOperations[Event.KeyboardEvent(key)] = action; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue