From d16751d036b7c1ba315473c7b41139f6e51fa414 Mon Sep 17 00:00:00 2001 From: liuyu <272912176@qq.com> Date: Thu, 1 Aug 2024 09:42:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMask=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/UI/UI_Panel/UI_MaskPanel.prefab | 120 ++++--- Assets/SandBox/JBQ/JBQTest.unity | 305 +++--------------- Assets/SandBox/JBQ/JBQ_Test.cs | 24 ++ Assets/SandBox/JBQ/JBQ_Test.cs.meta | 11 + Assets/Scripts/Project/Enum/Enums.cs | 15 + .../Project/UI/UI_Panel/UI_MaskPanel.cs | 89 +++-- .../ProjectBase/EventCenter/Enum_EventType.cs | 5 +- 7 files changed, 238 insertions(+), 331 deletions(-) create mode 100644 Assets/SandBox/JBQ/JBQ_Test.cs create mode 100644 Assets/SandBox/JBQ/JBQ_Test.cs.meta diff --git a/Assets/Resources/UI/UI_Panel/UI_MaskPanel.prefab b/Assets/Resources/UI/UI_Panel/UI_MaskPanel.prefab index 5934607..dd929b8 100644 --- a/Assets/Resources/UI/UI_Panel/UI_MaskPanel.prefab +++ b/Assets/Resources/UI/UI_Panel/UI_MaskPanel.prefab @@ -9,8 +9,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1739812074570663577} - - component: {fileID: 1739812074570663575} - - component: {fileID: 1739812074570663576} - component: {fileID: 1739812074570663574} m_Layer: 5 m_Name: UI_MaskPanel @@ -30,7 +28,8 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 8284933056051780802} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -39,44 +38,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &1739812074570663575 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1739812074570663578} - m_CullTransparentMesh: 1 ---- !u!114 &1739812074570663576 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1739812074570663578} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0, g: 0, b: 0, a: 0} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10907, 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 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 --- !u!114 &1739812074570663574 MonoBehaviour: m_ObjectHideFlags: 0 @@ -89,3 +50,80 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2b63019446a8ba3428d1055df6fb4366, type: 3} m_Name: m_EditorClassIdentifier: + fadeInSpeed: 0.5 +--- !u!1 &2272385754182984871 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8284933056051780802} + - component: {fileID: 5121238732433573415} + - component: {fileID: 6709792472113697369} + m_Layer: 5 + m_Name: Mask + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8284933056051780802 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2272385754182984871} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1739812074570663577} + 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_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &5121238732433573415 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2272385754182984871} + m_CullTransparentMesh: 1 +--- !u!114 &6709792472113697369 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2272385754182984871} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 diff --git a/Assets/SandBox/JBQ/JBQTest.unity b/Assets/SandBox/JBQ/JBQTest.unity index dc9ae0e..c745d45 100644 --- a/Assets/SandBox/JBQ/JBQTest.unity +++ b/Assets/SandBox/JBQ/JBQTest.unity @@ -238,112 +238,6 @@ MonoBehaviour: m_ShadowLayerMask: 1 m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} ---- !u!224 &930849161 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - m_PrefabInstance: {fileID: 1051681425} - m_PrefabAsset: {fileID: 0} ---- !u!1001 &1051681425 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 1507034761} - m_Modifications: - - target: {fileID: 1739812074570663576, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_Color.a - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_Pivot.x - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_Pivot.y - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_RootOrder - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_AnchorMax.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_AnchorMin.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663577, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1739812074570663578, guid: 0631a5a524453a64894fdbf946760a64, type: 3} - propertyPath: m_Name - value: UI_MaskPanel - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 0631a5a524453a64894fdbf946760a64, type: 3} --- !u!1 &1412047389 GameObject: m_ObjectHideFlags: 0 @@ -355,6 +249,8 @@ GameObject: - component: {fileID: 1412047392} - component: {fileID: 1412047391} - component: {fileID: 1412047390} + - component: {fileID: 1412047394} + - component: {fileID: 1412047393} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -380,7 +276,7 @@ Camera: m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} m_projectionMatrixMode: 1 m_GateFitMode: 2 m_FOVAxisMode: 0 @@ -428,173 +324,48 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1507034757 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1507034761} - - component: {fileID: 1507034760} - - component: {fileID: 1507034759} - - component: {fileID: 1507034758} - m_Layer: 5 - m_Name: Canvas - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1507034758 +--- !u!114 &1412047393 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1507034757} + m_GameObject: {fileID: 1412047389} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Script: {fileID: 11500000, guid: 83c0f087d2600824b823b4975105d63e, type: 3} m_Name: m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: +--- !u!114 &1412047394 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1412047389} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: serializedVersion: 2 - m_Bits: 4294967295 ---- !u!114 &1507034759 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1507034757} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, 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 - m_PresetInfoIsWorld: 0 ---- !u!223 &1507034760 -Canvas: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1507034757} - 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_VertexColorAlwaysGammaSpace: 0 - m_AdditionalShaderChannelsFlag: 25 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 ---- !u!224 &1507034761 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1507034757} - 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_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 930849161} - 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!1 &1972586253 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1972586256} - - component: {fileID: 1972586255} - - component: {fileID: 1972586254} - m_Layer: 0 - m_Name: EventSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1972586254 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1972586253} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} - m_Name: - m_EditorClassIdentifier: - m_SendPointerHoverToParent: 1 - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 ---- !u!114 &1972586255 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1972586253} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 10 ---- !u!4 &1972586256 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1972586253} - 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_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_VolumeFrameworkUpdateModeOption: 2 + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_AllowXRRendering: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 diff --git a/Assets/SandBox/JBQ/JBQ_Test.cs b/Assets/SandBox/JBQ/JBQ_Test.cs new file mode 100644 index 0000000..f72a94c --- /dev/null +++ b/Assets/SandBox/JBQ/JBQ_Test.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class JBQ_Test : MonoBehaviour +{ + + // Update is called once per frame + void Update() + { + if (Input.GetKeyDown(KeyCode.P)) + { + UIManager.Instance.ShowPanel(E_UI_Layer.System, (panel) => + { + panel.Init(); + }); + } + + if (Input.GetKeyDown(KeyCode.L)) + { + EventCenter.Instance.EventTrigger(Enum_EventType.HideMask); + } + } +} diff --git a/Assets/SandBox/JBQ/JBQ_Test.cs.meta b/Assets/SandBox/JBQ/JBQ_Test.cs.meta new file mode 100644 index 0000000..b0a55e0 --- /dev/null +++ b/Assets/SandBox/JBQ/JBQ_Test.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 83c0f087d2600824b823b4975105d63e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Project/Enum/Enums.cs b/Assets/Scripts/Project/Enum/Enums.cs index c8d9cc3..3c445fa 100644 --- a/Assets/Scripts/Project/Enum/Enums.cs +++ b/Assets/Scripts/Project/Enum/Enums.cs @@ -109,3 +109,18 @@ public enum E_ToolOrMaterial /// Material, } + +/// +/// 淡入淡出枚举 +/// +public enum E_FadeInAndOut +{ + /// + /// 淡入 + /// + FadeIn, + /// + /// 淡出 + /// + FadeOut, +} \ No newline at end of file diff --git a/Assets/Scripts/Project/UI/UI_Panel/UI_MaskPanel.cs b/Assets/Scripts/Project/UI/UI_Panel/UI_MaskPanel.cs index fb65e4f..32b22c1 100644 --- a/Assets/Scripts/Project/UI/UI_Panel/UI_MaskPanel.cs +++ b/Assets/Scripts/Project/UI/UI_Panel/UI_MaskPanel.cs @@ -1,55 +1,95 @@ using System.Collections; -using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UI_MaskPanel : BasePanel { - private float fadeInSpeed = 0.5f; // 淡入速度 - private float fadeOutSpeed = 0.5f; // 淡出速度 - private float pauseTime = 3f; // 停留时间 + /// + /// 淡入淡出速度0.5/s + /// + public float fadeInSpeed = 0.5f; // 淡入速度 + + /// + /// 初始化 + /// public void Init() { + FadeInAndOut(E_FadeInAndOut.FadeIn); + } + + /// + /// 淡入/出 + /// + /// + public void FadeInAndOut(E_FadeInAndOut type) + { + switch (type) + { + case E_FadeInAndOut.FadeIn: + StartCoroutine(FadeInAsync()); + break; + case E_FadeInAndOut.FadeOut: + StartCoroutine(FadeOutAsync()); + break; + } + + } - private void Start() + + /// + /// 隐藏蒙版 + /// + private void HideMask() { - StartCoroutine(FadeInAndOut()); + FadeInAndOut(E_FadeInAndOut.FadeOut); } - IEnumerator FadeInAndOut() + + /// + /// 淡入 + /// + /// + private IEnumerator FadeInAsync() { - Image image_Mask = GetControl("UI_MaskPanel"); // 淡入 float alpha = 0.0f; while (alpha < 1.0f) { alpha += fadeInSpeed * Time.deltaTime; - image_Mask.color = new Color(0, 0, 0, alpha); + alpha = Mathf.Clamp(alpha,0,1); + GetControl("Mask").color = new Color(0, 0, 0, alpha); yield return null; } + } - // 停留 - yield return new WaitForSeconds(pauseTime); - - // 淡出 - alpha = 1.0f; + /// + /// 淡出 + /// + /// + private IEnumerator FadeOutAsync() + { + // 淡入 + float alpha = 1.0f; while (alpha > 0.0f) { - alpha -= fadeOutSpeed * Time.deltaTime; - image_Mask.color = new Color(0, 0, 0, alpha); + alpha -= fadeInSpeed * Time.deltaTime; + alpha = Mathf .Clamp(alpha,0,1); + GetControl("Mask").color = new Color(0, 0, 0, alpha); yield return null; } - - + UIManager.Instance.HidePanel(); } + /// /// 显示 /// public override void ShowMe() { - - - +#if UNITY_EDITOR + EventCenter.Instance.AddEventListener(Enum_EventType.HideMask, HideMask); +#else + GameManager.EventMgr.AddEventListener(Enum_EventType.HideMask, HideMask); +#endif } /// @@ -57,6 +97,11 @@ public class UI_MaskPanel : BasePanel /// public override void HideMe() { - +#if UNITY_EDITOR + EventCenter.Instance.RemoveEventListener(Enum_EventType.HideMask, HideMask); +#else + GameManager.EventMgr.RemoveEventListener(Enum_EventType.HideMask, HideMask); +#endif + } } diff --git a/Assets/Scripts/ProjectBase/EventCenter/Enum_EventType.cs b/Assets/Scripts/ProjectBase/EventCenter/Enum_EventType.cs index 3d80bdc..18b4ec0 100644 --- a/Assets/Scripts/ProjectBase/EventCenter/Enum_EventType.cs +++ b/Assets/Scripts/ProjectBase/EventCenter/Enum_EventType.cs @@ -13,6 +13,9 @@ public enum Enum_EventType /// UpdateProgress, - + /// + /// 隐藏黑色蒙版 + /// + HideMask, }