diff options
author | chai <chaifix@163.com> | 2020-10-11 09:12:08 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-10-11 09:12:08 +0800 |
commit | b1276a1b76ac3b87add90e0c6b887d5afea1cfea (patch) | |
tree | ae12e1bc24f6907c9870bf062d020d6ce1db6fa1 | |
parent | 8d89ca7b0662cff2a93b33ed92205ff3f6170436 (diff) |
*event system鍒濇帰
25 files changed, 998 insertions, 230 deletions
diff --git a/Assets/Art.meta b/Assets/Art.meta new file mode 100644 index 0000000..6f46d74 --- /dev/null +++ b/Assets/Art.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 87fc5487170fb42429c82fa0a749f025 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/Sprite.meta b/Assets/Art/Sprite.meta new file mode 100644 index 0000000..2c6c175 --- /dev/null +++ b/Assets/Art/Sprite.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dec554caba0004a45b521188c1b29be1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/Sprite/pico8.png b/Assets/Art/Sprite/pico8.png Binary files differnew file mode 100644 index 0000000..0d11f85 --- /dev/null +++ b/Assets/Art/Sprite/pico8.png diff --git a/Assets/Art/Sprite/pico8.png.meta b/Assets/Art/Sprite/pico8.png.meta new file mode 100644 index 0000000..f1d774f --- /dev/null +++ b/Assets/Art/Sprite/pico8.png.meta @@ -0,0 +1,106 @@ +fileFormatVersion: 2 +guid: e0e4486c00f607e45928a93eaea43e63 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: 1 + wrapV: 1 + wrapW: -1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/demo.unity b/Assets/Scenes/2D_3D_Buttons.unity index 140edec..7cbb577 100644 --- a/Assets/Scenes/demo.unity +++ b/Assets/Scenes/2D_3D_Buttons.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.4465782, g: 0.49641252, b: 0.5748167, a: 1} + m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1} --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 @@ -88,6 +88,7 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -112,150 +113,221 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &533663744 +--- !u!1 &228417949 GameObject: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} serializedVersion: 5 m_Component: - - component: {fileID: 533663745} - - component: {fileID: 533663748} - - component: {fileID: 533663747} - - component: {fileID: 533663746} - - component: {fileID: 533663749} - m_Layer: 5 - m_Name: Button + - component: {fileID: 228417951} + - component: {fileID: 228417950} + - component: {fileID: 228417952} + - component: {fileID: 228417953} + m_Layer: 8 + m_Name: PicoButton m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!224 &533663745 -RectTransform: +--- !u!212 &228417950 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 228417949} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + 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: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: e0e4486c00f607e45928a93eaea43e63, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1.28, y: 1.28} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 +--- !u!4 &228417951 +Transform: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 533663744} + m_GameObject: {fileID: 228417949} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 2.53, y: 1.98, z: 3.15} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 640337471} - m_Father: {fileID: 800438999} - m_RootOrder: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 160, y: 30} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &533663746 +--- !u!114 &228417952 MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 533663744} + m_GameObject: {fileID: 228417949} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: b55754d97ca63cd4dbfeea25c980c065, type: 3} + m_Script: {fileID: 11500000, guid: 8048cdebd1089744b99076ef93c3f3b2, type: 3} m_Name: m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 0} - m_OnClick: - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 533663749} - m_MethodName: OnClickCallback - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, Assembly-CSharp, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null ---- !u!114 &533663747 -MonoBehaviour: +--- !u!61 &228417953 +BoxCollider2D: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 533663744} + m_GameObject: {fileID: 228417949} m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: bd103b5bbc9cef740b4136f9f7a7b109, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Density: 1 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, Assembly-CSharp, - Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &533663748 -CanvasRenderer: + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1.28, y: 1.28} + newSize: {x: 1.28, y: 1.28} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1.28, y: 1.28} + m_EdgeRadius: 0 +--- !u!1 &375808508 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 375808512} + - component: {fileID: 375808511} + - component: {fileID: 375808510} + - component: {fileID: 375808509} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &375808509 +MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 533663744} ---- !u!114 &533663749 + m_GameObject: {fileID: 375808508} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 67bf38e07c362674ebc60bfbd6dafa3a, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &375808510 MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 533663744} + m_GameObject: {fileID: 375808508} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 888d6900b9dcda148bf20be9c4b300c9, type: 3} + m_Script: {fileID: 11500000, guid: debcf26b89013e446a6de5574715c5af, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &640337470 + 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 &375808511 +Canvas: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 375808508} + 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 &375808512 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 375808508} + 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: 408402000} + m_Father: {fileID: 0} + m_RootOrder: 6 + 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!1 &408401999 GameObject: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} serializedVersion: 5 m_Component: - - component: {fileID: 640337471} - - component: {fileID: 640337473} - - component: {fileID: 640337472} + - component: {fileID: 408402000} + - component: {fileID: 408402002} + - component: {fileID: 408402001} m_Layer: 5 m_Name: Text m_TagString: Untagged @@ -263,37 +335,37 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!224 &640337471 +--- !u!224 &408402000 RectTransform: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 640337470} + m_GameObject: {fileID: 408401999} 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: 533663745} + m_Father: {fileID: 375808512} 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: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 312, y: -175.5} + m_SizeDelta: {x: 624, y: 351} m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &640337472 +--- !u!114 &408402001 MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 640337470} + m_GameObject: {fileID: 408401999} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 09f4224b0cded254a977e1ac3c9e2470, type: 3} m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 m_OnCullStateChanged: m_PersistentCalls: @@ -302,118 +374,135 @@ MonoBehaviour: Version=0.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 + m_FontSize: 20 m_FontStyle: 0 m_BestFit: 0 - m_MinSize: 10 + m_MinSize: 2 m_MaxSize: 40 - m_Alignment: 4 + m_Alignment: 0 m_AlignByGeometry: 0 m_RichText: 1 m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Button ---- !u!222 &640337473 + m_Text: "3d capsule button \n2d sprite button\nin world space not in canvas" +--- !u!222 &408402002 CanvasRenderer: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 640337470} ---- !u!1 &800438995 + m_GameObject: {fileID: 408401999} +--- !u!1 &925175240 GameObject: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} serializedVersion: 5 m_Component: - - component: {fileID: 800438999} - - component: {fileID: 800438998} - - component: {fileID: 800438997} - - component: {fileID: 800438996} - m_Layer: 5 - m_Name: Canvas + - component: {fileID: 925175244} + - component: {fileID: 925175243} + - component: {fileID: 925175242} + - component: {fileID: 925175241} + - component: {fileID: 925175245} + - component: {fileID: 925175246} + m_Layer: 0 + m_Name: Capsule m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &800438996 -MonoBehaviour: +--- !u!23 &925175241 +MeshRenderer: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 800438995} + m_GameObject: {fileID: 925175240} m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 67bf38e07c362674ebc60bfbd6dafa3a, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 ---- !u!114 &800438997 -MonoBehaviour: + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + 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!136 &925175242 +CapsuleCollider: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 800438995} + m_GameObject: {fileID: 925175240} + m_Material: {fileID: 0} + m_IsTrigger: 0 m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: debcf26b89013e446a6de5574715c5af, 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 &800438998 -Canvas: + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} +--- !u!33 &925175243 +MeshFilter: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 800438995} - 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 &800438999 -RectTransform: + m_GameObject: {fileID: 925175240} + m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &925175244 +Transform: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 800438995} + m_GameObject: {fileID: 925175240} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 494.5, y: 307, z: 0} + m_LocalPosition: {x: 5.0195312, y: 1.9179688, z: 5.3847656} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 533663745} + m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0.5, y: 0.5} +--- !u!136 &925175245 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 925175240} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &925175246 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 925175240} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 71800034947a58040a0004d4225a9007, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1360287297 GameObject: m_ObjectHideFlags: 0 @@ -425,6 +514,7 @@ GameObject: - component: {fileID: 1360287300} - component: {fileID: 1360287299} - component: {fileID: 1360287298} + - component: {fileID: 1360287302} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -470,13 +560,14 @@ Camera: m_Depth: -1 m_CullingMask: serializedVersion: 2 - m_Bits: 4294967295 + m_Bits: 4294967039 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 @@ -487,13 +578,27 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1360287297} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalRotation: {x: -0.08693287, y: 0.35827526, z: -0.033527985, w: -0.928955} + m_LocalPosition: {x: 9.827096, y: 3.2698436, z: 0.07919407} 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 &1360287302 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1360287297} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b2bb18305a46ea44686ad8cdffbb3a58, type: 3} + m_Name: + m_EditorClassIdentifier: + m_EventMask: + serializedVersion: 2 + m_Bits: 4294967295 --- !u!1 &1400184286 GameObject: m_ObjectHideFlags: 0 @@ -559,6 +664,94 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1461691731 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1461691735} + - component: {fileID: 1461691734} + - component: {fileID: 1461691733} + - component: {fileID: 1461691732} + m_Layer: 8 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1461691732 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1461691731} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 055a0cdd9d5d3e0489f854f7bdf22ded, type: 3} + m_Name: + m_EditorClassIdentifier: + m_EventMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!124 &1461691733 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1461691731} + m_Enabled: 1 +--- !u!20 &1461691734 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1461691731} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 4 + m_BackGroundColor: {r: 0.5735294, g: 0.73937905, b: 1, a: 0} + 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: 1 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 256 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_AllowMSAA: 0 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1461691735 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1461691731} + 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: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1827934287 GameObject: m_ObjectHideFlags: 0 @@ -619,5 +812,5 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scenes/demo.unity.meta b/Assets/Scenes/2D_3D_Buttons.unity.meta index 5d6fb8e..5d6fb8e 100644 --- a/Assets/Scenes/demo.unity.meta +++ b/Assets/Scenes/2D_3D_Buttons.unity.meta diff --git a/Assets/Scenes/EventTrigger.unity b/Assets/Scenes/EventTrigger.unity new file mode 100644 index 0000000..d6ec968 --- /dev/null +++ b/Assets/Scenes/EventTrigger.unity @@ -0,0 +1,309 @@ +%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: 8 + 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.44657826, g: 0.49641263, b: 0.57481676, a: 1} +--- !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_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 9 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 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: 0 + 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 &621282802 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 621282806} + - component: {fileID: 621282805} + - component: {fileID: 621282804} + - component: {fileID: 621282803} + 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 &621282803 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 621282802} + m_Enabled: 1 +--- !u!124 &621282804 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 621282802} + m_Enabled: 1 +--- !u!20 &621282805 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 621282802} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + 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 &621282806 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 621282802} + 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} +--- !u!1 &974964877 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 974964879} + - component: {fileID: 974964878} + m_Layer: 0 + m_Name: GameObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &974964878 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 974964877} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 17193886a08901d45ba6c4e9cebb18f6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Delegates: + - eventID: 5 + callback: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.EventSystems.EventTrigger+TriggerEvent, Assembly-CSharp, + Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + delegates: [] +--- !u!4 &974964879 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 974964877} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -1.9470181, y: 3.4935284, z: 3.0572262} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1034744955 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1034744957} + - component: {fileID: 1034744956} + 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 &1034744956 +Light: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1034744955} + 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_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1034744957 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1034744955} + 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} diff --git a/Assets/Scenes/EventTrigger.unity.meta b/Assets/Scenes/EventTrigger.unity.meta new file mode 100644 index 0000000..3781e50 --- /dev/null +++ b/Assets/Scenes/EventTrigger.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7dbaabaf445470c499c84587ea4d4c8b +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/CapsuleButton.cs b/Assets/Scripts/CapsuleButton.cs new file mode 100644 index 0000000..9adee0f --- /dev/null +++ b/Assets/Scripts/CapsuleButton.cs @@ -0,0 +1,24 @@ +锘縰sing System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.EventSystems; + +public class CapsuleButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler +{ + public virtual void OnPointerClick(PointerEventData eventData) + { + Debug.Log("CapsuleButton.OnPointerClick"); + } + + public virtual void OnPointerUp(PointerEventData eventData) + { + Debug.Log("CapsuleButton.OnPointerUp"); + } + + public virtual void OnPointerDown(PointerEventData eventData) + { + Debug.Log("CapsuleButton.OnPointerDown"); + } + +} diff --git a/Assets/Scripts/CapsuleButton.cs.meta b/Assets/Scripts/CapsuleButton.cs.meta new file mode 100644 index 0000000..7ec7b59 --- /dev/null +++ b/Assets/Scripts/CapsuleButton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 71800034947a58040a0004d4225a9007 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PicoButton.cs b/Assets/Scripts/PicoButton.cs new file mode 100644 index 0000000..385f90f --- /dev/null +++ b/Assets/Scripts/PicoButton.cs @@ -0,0 +1,24 @@ +锘縰sing System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.EventSystems; + +public class PicoButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler +{ + public virtual void OnPointerClick(PointerEventData eventData) + { + Debug.Log("PicoButton.OnPointerClick"); + } + + public virtual void OnPointerUp(PointerEventData eventData) + { + Debug.Log("PicoButton.OnPointerUp"); + } + + public virtual void OnPointerDown(PointerEventData eventData) + { + Debug.Log("PicoButton.OnPointerDown"); + } + +} diff --git a/Assets/Scripts/PicoButton.cs.meta b/Assets/Scripts/PicoButton.cs.meta new file mode 100644 index 0000000..76c9e9b --- /dev/null +++ b/Assets/Scripts/PicoButton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8048cdebd1089744b99076ef93c3f3b2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs index 62e6cb4..7b5a60d 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs @@ -2,7 +2,7 @@ namespace UnityEngine.EventSystems { public abstract class AbstractEventData { - protected bool m_Used; + protected bool m_Used; // 当前事件是否被吞(被处理) public virtual void Reset() { diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs index 7ddabb8..3456e7b 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs @@ -9,6 +9,7 @@ namespace UnityEngine.EventSystems [AddComponentMenu("Event/Event System")] public class EventSystem : UIBehaviour { + // 获得当前EventSystem挂着的BaseInputModule的派生类,一般来说只会挂一个StandableInputModule private List<BaseInputModule> m_SystemInputModules = new List<BaseInputModule>(); private BaseInputModule m_CurrentInputModule; @@ -20,7 +21,7 @@ namespace UnityEngine.EventSystems private GameObject m_FirstSelected; [SerializeField] - private bool m_sendNavigationEvents = true; + private bool m_sendNavigationEvents = true; // Should the EventSystem allow navigation events (move / submit / cancel). public bool sendNavigationEvents { @@ -73,14 +74,15 @@ namespace UnityEngine.EventSystems protected EventSystem() {} + //c 把挂着的input modules加入m_SystemInputModules public void UpdateModules() - { - GetComponents(m_SystemInputModules); - for (int i = m_SystemInputModules.Count - 1; i >= 0; i--) + { + // 拿到当前EventSystem下面挂着的inputmodule,通常来说只会挂一个standaloneInputModule + GetComponents(m_SystemInputModules); + for (int i = m_SystemInputModules.Count - 1; i >= 0; i--) { if (m_SystemInputModules[i] && m_SystemInputModules[i].IsActive()) continue; - m_SystemInputModules.RemoveAt(i); } } @@ -177,6 +179,7 @@ namespace UnityEngine.EventSystems private static readonly Comparison<RaycastResult> s_RaycastComparer = RaycastComparer; + // 从PointerInputModule.GetTouchPointerEventData()来的触摸数据 public void RaycastAll(PointerEventData eventData, List<RaycastResult> raycastResults) { raycastResults.Clear(); @@ -193,11 +196,13 @@ namespace UnityEngine.EventSystems raycastResults.Sort(s_RaycastComparer); } + //c 是否点击到某个物体 public bool IsPointerOverGameObject() { return IsPointerOverGameObject(PointerInputModule.kMouseLeftId); } + //c 是否点击到某个物体 public bool IsPointerOverGameObject(int pointerId) { if (m_CurrentInputModule == null) @@ -233,8 +238,14 @@ namespace UnityEngine.EventSystems base.OnDisable(); } + protected virtual void OnApplicationFocus(bool hasFocus) + { + m_HasFocus = hasFocus; + } + private void TickModules() { + // 只有standaloneInputModule一个 for (var i = 0; i < m_SystemInputModules.Count; i++) { if (m_SystemInputModules[i] != null) @@ -242,17 +253,15 @@ namespace UnityEngine.EventSystems } } - protected virtual void OnApplicationFocus(bool hasFocus) - { - m_HasFocus = hasFocus; - } - + //c 事件处理跑在一个update里,以轮训的方式检测输入 protected virtual void Update() { if (current != this) return; + TickModules(); + // 将m_CurrentInputModule设置为m_SystemInputModules第一个可用的module bool changedModule = false; for (var i = 0; i < m_SystemInputModules.Count; i++) { @@ -267,7 +276,6 @@ namespace UnityEngine.EventSystems break; } } - // no event module set... set the first valid one... if (m_CurrentInputModule == null) { @@ -283,6 +291,7 @@ namespace UnityEngine.EventSystems } } + //c 执行事件处理主入口,通常情况下,如果没有自定义的inputModule,就是走StandaloneInputModule的Process if (!changedModule && m_CurrentInputModule != null) m_CurrentInputModule.Process(); } diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs index 6f4f179..11d1c1c 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventTrigger.cs @@ -5,6 +5,9 @@ using UnityEngine.Serialization; namespace UnityEngine.EventSystems { + //c 一个辅助组件,给一个事件添加自定义的回调函数 + //继承了所有接口,效率不高,慎用。只是比较方便 + [AddComponentMenu("Event/Event Trigger")] public class EventTrigger : MonoBehaviour, diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs index bf77717..71fd9f3 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs @@ -233,8 +233,10 @@ namespace UnityEngine.EventSystems } } + //IEventSystemHandler是所有接口的基类 private static readonly ObjectPool<List<IEventSystemHandler>> s_HandlerListPool = new ObjectPool<List<IEventSystemHandler>>(null, l => l.Clear()); + // 向target gameobject发送一个事件,对每个实现了T接口的类执行functor方法(就是接口中定义的回调) public static bool Execute<T>(GameObject target, BaseEventData eventData, EventFunction<T> functor) where T : IEventSystemHandler { var internalHandlers = s_HandlerListPool.Get(); @@ -242,6 +244,8 @@ namespace UnityEngine.EventSystems // if (s_InternalHandlers.Count > 0) // Debug.Log("Executinng " + typeof (T) + " on " + target); + // 拿到实现了T接口的组件,调用对应的方法 + for (var i = 0; i < internalHandlers.Count; i++) { T arg; @@ -289,6 +293,7 @@ namespace UnityEngine.EventSystems return null; } + //c component是否匹配类型T且是否被激活 private static bool ShouldSendToComponent<T>(Component component) where T : IEventSystemHandler { var valid = component is T; @@ -315,8 +320,10 @@ namespace UnityEngine.EventSystems var components = ListPool<Component>.Get(); go.GetComponents(components); + // 遍历所有的组件,找到匹配类型T的 for (var i = 0; i < components.Count; i++) { + // 如果不匹配类型T,跳过这个 if (!ShouldSendToComponent<T>(components[i])) continue; diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs index a761057..8d22d04 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInput.cs @@ -1,5 +1,8 @@ namespace UnityEngine.EventSystems { + + //c 对UnityEngine.Input进行一次简单包装,方便调试 + // 另外如果希望自定义输入,继承这个类,并实现这些属性 public class BaseInput : UIBehaviour { public virtual string compositionString diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs index 7125a4d..7661a8e 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs @@ -14,9 +14,12 @@ namespace UnityEngine.EventSystems private EventSystem m_EventSystem; private BaseEventData m_BaseEventData; - protected BaseInput m_InputOverride; - private BaseInput m_DefaultInput; - +#region 输入系统 + // 如果m_InputOverride不为空就用它,否则用默认的m_DefaultInput + // 如果要自己实现BaseInput,继承此类并给这个字段赋值 + // StandaloneInputModule没有自定义,直接采用的是BaseInput + protected BaseInput m_InputOverride; + private BaseInput m_DefaultInput; public BaseInput input { get @@ -40,12 +43,12 @@ namespace UnityEngine.EventSystems if (m_DefaultInput == null) m_DefaultInput = gameObject.AddComponent<BaseInput>(); } - return m_DefaultInput; } } +#endregion - protected EventSystem eventSystem + protected EventSystem eventSystem { get { return m_EventSystem; } } @@ -54,13 +57,13 @@ namespace UnityEngine.EventSystems { base.OnEnable(); m_EventSystem = GetComponent<EventSystem>(); - m_EventSystem.UpdateModules(); + m_EventSystem.UpdateModules(); // 把此input module加入EventSystem } protected override void OnDisable() { - m_EventSystem.UpdateModules(); - base.OnDisable(); + m_EventSystem.UpdateModules();// 把此input module移出EventSystem + base.OnDisable(); } public abstract void Process(); diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs index d31f433..9103162 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs @@ -16,7 +16,7 @@ namespace UnityEngine.EventSystems protected bool GetPointerData(int id, out PointerEventData data, bool create) { - if (!m_PointerData.TryGetValue(id, out data) && create) + if (!m_PointerData.TryGetValue(id, out data) && create) // 一个池子 { data = new PointerEventData(eventSystem) { @@ -33,29 +33,33 @@ namespace UnityEngine.EventSystems m_PointerData.Remove(data.pointerId); } + //c 根据touch数据得到pointEventData,并且保存raycaster结果 protected PointerEventData GetTouchPointerEventData(Touch input, out bool pressed, out bool released) { PointerEventData pointerData; - var created = GetPointerData(input.fingerId, out pointerData, true); + var created = GetPointerData(input.fingerId, out pointerData, true); // 拿到存储结构,返回是否是新建结构 pointerData.Reset(); - pressed = created || (input.phase == TouchPhase.Began); - released = (input.phase == TouchPhase.Canceled) || (input.phase == TouchPhase.Ended); + // pressed和released用来判断抬起或者放下 - if (created) + pressed = created || (input.phase == TouchPhase.Began); // 如果结构是新建的或input phase是bagan,说明是刚按下 + released = (input.phase == TouchPhase.Canceled) || (input.phase == TouchPhase.Ended); // 如果phase是这两种,说明是抬起来了 + + if (created)//如果是新建的,记录下起始位置,否则还保留旧值,下面用来计算delta pointerData.position = input.position; - if (pressed) + if (pressed)//如果是刚按下,delta置为0 pointerData.delta = Vector2.zero; else - pointerData.delta = input.position - pointerData.position; + pointerData.delta = input.position - pointerData.position; // 计算delta - pointerData.position = input.position; + pointerData.position = input.position; // 计算完delta后覆盖 - pointerData.button = PointerEventData.InputButton.Left; + pointerData.button = PointerEventData.InputButton.Left; // 这里不知道为什么 - eventSystem.RaycastAll(pointerData, m_RaycastResultCache); + // 用这个触摸数据做射线检测,检测结果在m_RaycastResultCache + eventSystem.RaycastAll(pointerData, m_RaycastResultCache); var raycast = FindFirstRaycast(m_RaycastResultCache); pointerData.pointerCurrentRaycast = raycast; diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs index ee6f216..f9a2f77 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs @@ -1,3 +1,9 @@ +/* + * StandaloneInputModule : + * PointerInputModule : + * BaseInputModule + */ + using System; using UnityEngine; using UnityEngine.Serialization; @@ -11,6 +17,7 @@ namespace UnityEngine.EventSystems private Vector2 m_LastMoveVector; private int m_ConsecutiveMoveCount = 0; + // 上一个鼠标位置和当前鼠标位置,每帧更新 private Vector2 m_LastMousePosition; private Vector2 m_MousePosition; @@ -136,11 +143,14 @@ namespace UnityEngine.EventSystems } } + //c 更新鼠标坐标 public override void UpdateModule() { + // 如果没有获取焦点,且忽略没有焦点时的事件,返回(除非开启远程连接,否则会这样) if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus()) return; + // 更新鼠标位置 m_LastMousePosition = m_MousePosition; m_MousePosition = input.mousePosition; } @@ -190,41 +200,49 @@ namespace UnityEngine.EventSystems base.DeactivateModule(); ClearSelection(); } - + + //c input module事件处理主入口 public override void Process() { - if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus()) + if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus()) // 如果没有获取焦点,不需要处理 return; + //event 给选中的对象发布更新事件 bool usedEvent = SendUpdateEventToSelectedObject(); + // 如果勾上了,发送move , submit, cancel事件 if (eventSystem.sendNavigationEvents) { if (!usedEvent) - usedEvent |= SendMoveEventToSelectedObject(); + usedEvent |= SendMoveEventToSelectedObject(); //event 键盘方向键移动时给eventSystem选中的对象发布IMoveHandler事件 if (!usedEvent) - SendSubmitEventToSelectedObject(); + SendSubmitEventToSelectedObject(); //event 如果按了相应按键,发布submit或者cancel事件 } + // 模拟触摸或鼠标输入 // touch needs to take precedence because of the mouse emulation layer - if (!ProcessTouchEvents() && input.mousePresent) + usedEvent = ProcessTouchEvents(); //event 发布触摸事件 + + if(!usedEvent && input.mousePresent) ProcessMouseEvent(); } + //c 触摸事件 private bool ProcessTouchEvents() { - for (int i = 0; i < input.touchCount; ++i) + for (int i = 0; i < input.touchCount; ++i) //多点触控 { Touch touch = input.GetTouch(i); if (touch.type == TouchType.Indirect) continue; - bool released; - bool pressed; - var pointer = GetTouchPointerEventData(touch, out pressed, out released); + bool released; // 这是一个手指抬起操作 + bool pressed; // 这是一个手指放下操作 + var pointer = GetTouchPointerEventData(touch, out pressed, out released); // 射线检测并保存检测结果 + // 处理触摸或抬起反馈,已经准备好了被触摸的物体 ProcessTouchPress(pointer, pressed, released); if (!released) @@ -238,10 +256,12 @@ namespace UnityEngine.EventSystems return input.touchCount > 0; } + //c 处理触摸\抬起 protected void ProcessTouchPress(PointerEventData pointerEvent, bool pressed, bool released) { var currentOverGo = pointerEvent.pointerCurrentRaycast.gameObject; + // 触摸反馈 // PointerDown notification if (pressed) { @@ -261,6 +281,7 @@ namespace UnityEngine.EventSystems pointerEvent.pointerEnter = currentOverGo; } + //event IPointerDownHandler // search for the control that will receive the press // if we can't find a press handler set the press // handler to be what would receive a click. @@ -301,6 +322,7 @@ namespace UnityEngine.EventSystems ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag); } + // 抬起反馈 // PointerUp notification if (released) { @@ -310,14 +332,14 @@ namespace UnityEngine.EventSystems // Debug.Log("KeyCode: " + pointer.eventData.keyCode); // see if we mouse up on the same element that we clicked on... - var pointerUpHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo); + var pointerUpHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo); // 从这个对象开始往上找,直到一个挂了继承了IPointerClickHandler的组件 // PointerClick and Drop events - if (pointerEvent.pointerPress == pointerUpHandler && pointerEvent.eligibleForClick) + if (pointerEvent.pointerPress == pointerUpHandler && pointerEvent.eligibleForClick) //只有在pointerPress == pointerUpHandler时才会触发click事件 { ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerClickHandler); } - else if (pointerEvent.pointerDrag != null && pointerEvent.dragging) + else if (pointerEvent.pointerDrag != null && pointerEvent.dragging) // 如果两者不相等,触发drop事件 { ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.dropHandler); } @@ -346,6 +368,8 @@ namespace UnityEngine.EventSystems if (eventSystem.currentSelectedGameObject == null) return false; + // 发布submit事件或者cancel事件 + var data = GetBaseEventData(); if (input.GetButtonDown(m_SubmitButton)) ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler); @@ -386,15 +410,16 @@ namespace UnityEngine.EventSystems float time = Time.unscaledTime; Vector2 movement = GetRawMoveVector(); - if (Mathf.Approximately(movement.x, 0f) && Mathf.Approximately(movement.y, 0f)) + if (Mathf.Approximately(movement.x, 0f) && Mathf.Approximately(movement.y, 0f)) // 如果键盘方向键没动,返回 { m_ConsecutiveMoveCount = 0; return false; } + //allow即是否允许发布事件 // If user pressed key again, always allow event bool allow = input.GetButtonDown(m_HorizontalAxis) || input.GetButtonDown(m_VerticalAxis); - bool similarDir = (Vector2.Dot(movement, m_LastMoveVector) > 0); + bool similarDir = (Vector2.Dot(movement, m_LastMoveVector) > 0); // 和之前的方向是否夹角在90°以内,如果是的话说明很接近 if (!allow) { // Otherwise, user held down key or axis. @@ -408,15 +433,18 @@ namespace UnityEngine.EventSystems if (!allow) return false; + // 发布IMoveHandler事件 + // Debug.Log(m_ProcessingEvent.rawType + " axis:" + m_AllowAxisEvents + " value:" + "(" + x + "," + y + ")"); var axisEventData = GetAxisEventData(movement.x, movement.y, 0.6f); if (axisEventData.moveDir != MoveDirection.None) { - ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisEventData, ExecuteEvents.moveHandler); + ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisEventData, ExecuteEvents.moveHandler); // IMoveHandler.OnMove if (!similarDir) m_ConsecutiveMoveCount = 0; m_ConsecutiveMoveCount++; + m_PrevActionTime = time; m_LastMoveVector = movement; } @@ -473,6 +501,7 @@ namespace UnityEngine.EventSystems return false; var data = GetBaseEventData(); + //event 向eventSystem当前选中的gameobject发布一个更新事件IUpdateSelectedHandler,比如inputfield ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.updateSelectedHandler); return data.used; } diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs index 4f04f42..58ac97c 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs @@ -4,13 +4,15 @@ using UnityEngine.Serialization; namespace UnityEngine.EventSystems { - [Obsolete("TouchInputModule is no longer required as Touch input is now handled in StandaloneInputModule.")] + //c TouchInputModule被废弃了,统一在standaloneInputModule中处理 + [Obsolete("TouchInputModule is no longer required as Touch input is now handled in StandaloneInputModule.")] [AddComponentMenu("Event/Touch Input Module")] public class TouchInputModule : PointerInputModule { protected TouchInputModule() {} + // 触摸点位置 private Vector2 m_LastMousePosition; private Vector2 m_MousePosition; @@ -31,6 +33,7 @@ namespace UnityEngine.EventSystems set { m_ForceModuleActive = value; } } + //c 更新鼠标(触摸点)位置 public override void UpdateModule() { m_LastMousePosition = m_MousePosition; diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs index 12a339b..666ef8d 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/RaycastResult.cs @@ -1,5 +1,6 @@ namespace UnityEngine.EventSystems { + // UGUI射线检测结果 public struct RaycastResult { private GameObject m_GameObject; // Game object hit by the raycast diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs index 783cf95..6346938 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs @@ -13,6 +13,7 @@ namespace UnityEngine.EventSystems protected Physics2DRaycaster() {} + // 发射线 public override void Raycast(PointerEventData eventData, List<RaycastResult> resultAppendList) { if (eventCamera == null) diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs index 2b4bea3..c7d431c 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs @@ -3,6 +3,8 @@ using UnityEngine.UI; namespace UnityEngine.EventSystems { + //c 投射3D物体的相机挂这个脚本 + /// <summary> /// Simple event system using physics raycasts. /// </summary> @@ -66,7 +68,7 @@ namespace UnityEngine.EventSystems { ray = eventCamera.ScreenPointToRay(eventData.position); // compensate far plane distance - see MouseEvents.cs - float projectionDirection = ray.direction.z; + float projectionDirection = ray.direction.z; // ray.direction是归一化了的 distanceToClipPlane = Mathf.Approximately(0.0f, projectionDirection) ? Mathf.Infinity : Mathf.Abs((eventCamera.farClipPlane - eventCamera.nearClipPlane) / projectionDirection); @@ -78,6 +80,7 @@ namespace UnityEngine.EventSystems if (eventCamera == null || !eventCamera.pixelRect.Contains(eventData.position)) return; + // 根据触摸数据拿到射线 Ray ray; float distanceToClipPlane; ComputeRayAndDistance(eventData, out ray, out distanceToClipPlane); diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/InputField.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/InputField.cs index d203e97..1f3267a 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/InputField.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/InputField.cs @@ -1237,6 +1237,7 @@ namespace UnityEngine.UI KeyPressed(e); } + //c IUpdateSelectedHandler的接口 public virtual void OnUpdateSelected(BaseEventData eventData) { if (!isFocused) |