模式切换动画

This commit is contained in:
wulongxiao 2024-12-29 17:27:33 +08:00
parent c070c3b529
commit 00a95b5426
5 changed files with 498 additions and 17 deletions

View File

@ -526,6 +526,151 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &617219116198635587
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2372872097891136782}
- component: {fileID: 5930888730339565146}
- component: {fileID: 6299092088638637511}
- component: {fileID: 5283151450563293758}
- component: {fileID: 6421841758342192495}
- component: {fileID: 5840664033343851766}
m_Layer: 5
m_Name: CheckpointsBox
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2372872097891136782
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 617219116198635587}
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:
- {fileID: 6335397886766934478}
m_Father: {fileID: 3011360593928271564}
m_RootOrder: 1
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: 1.1064, y: 204.69653}
m_SizeDelta: {x: 600, y: 750}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5930888730339565146
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 617219116198635587}
m_CullTransparentMesh: 1
--- !u!114 &6299092088638637511
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 617219116198635587}
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: 1, g: 1, b: 1, 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 &5283151450563293758
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 617219116198635587}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Content: {fileID: 3215173789656602693}
m_Horizontal: 1
m_Vertical: 0
m_MovementType: 1
m_Elasticity: 0.1
m_Inertia: 1
m_DecelerationRate: 0.135
m_ScrollSensitivity: 1
m_Viewport: {fileID: 6335397886766934478}
m_HorizontalScrollbar: {fileID: 0}
m_VerticalScrollbar: {fileID: 0}
m_HorizontalScrollbarVisibility: 2
m_VerticalScrollbarVisibility: 2
m_HorizontalScrollbarSpacing: -3
m_VerticalScrollbarSpacing: -3
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &6421841758342192495
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 617219116198635587}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: 600
m_MinHeight: 750
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!114 &5840664033343851766
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 617219116198635587}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 36a154c6ab438304392f989d2d6ee437, type: 3}
m_Name:
m_EditorClassIdentifier:
_modePanel: {fileID: 1310652693}
_text: {fileID: 3011360593470444517}
OBJ: {fileID: 617219116198635587}
--- !u!1 &1572365498857213021
GameObject:
m_ObjectHideFlags: 0
@ -1307,9 +1452,9 @@ RectTransform:
m_Father: {fileID: 3011360593094855125}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 314.8496}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 68}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1104162584
@ -5598,8 +5743,8 @@ RectTransform:
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: 4.0702}
m_SizeDelta: {x: 464, y: 77.8596}
m_AnchoredPosition: {x: -1.9946, y: 4.0702}
m_SizeDelta: {x: 328.3699, y: 77.8596}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3011360593470444516
CanvasRenderer:
@ -5631,9 +5776,9 @@ MonoBehaviour:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 56
m_FontSize: 50
m_FontStyle: 0
m_BestFit: 0
m_BestFit: 1
m_MinSize: 0
m_MaxSize: 77
m_Alignment: 4
@ -6852,8 +6997,9 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 3011360593699687250}
- component: {fileID: 901532650777563773}
m_Layer: 5
m_Name: TipMid
m_Name: guanqia
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -6873,14 +7019,34 @@ RectTransform:
m_Children:
- {fileID: 3011360593362587367}
- {fileID: 3011360594259349989}
m_Father: {fileID: 3011360593928271564}
m_RootOrder: 1
m_Father: {fileID: 3215173789656602693}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 50, y: -470}
m_SizeDelta: {x: 100, y: 100}
m_AnchoredPosition: {x: 300, y: -366.5}
m_SizeDelta: {x: 600, y: 733}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &901532650777563773
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3011360593699687251}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: 600
m_MinHeight: 733
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!1 &3011360593729086423
GameObject:
m_ObjectHideFlags: 0
@ -8013,7 +8179,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 50, y: -870}
m_AnchoredPosition: {x: 50, y: -294}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &3011360593866302987
@ -8350,14 +8516,14 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3011360594066592782}
- {fileID: 3011360593699687250}
- {fileID: 2372872097891136782}
- {fileID: 3011360593852809512}
m_Father: {fileID: 3011360593841887782}
m_RootOrder: 1
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: 593}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &3011360593930044813
@ -8937,7 +9103,7 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3011360594066592783}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
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
@ -8949,7 +9115,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 50, y: -50}
m_AnchoredPosition: {x: 50, y: 567}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &3011360594066920931
@ -10857,6 +11023,97 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &4681035672399457600
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6335397886766934478}
- component: {fileID: 3750459843292451767}
- component: {fileID: 5108424620838132395}
- component: {fileID: 5785555120566224879}
m_Layer: 5
m_Name: Viewport
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6335397886766934478
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4681035672399457600}
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:
- {fileID: 3215173789656602693}
m_Father: {fileID: 2372872097891136782}
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: -17}
m_Pivot: {x: 0, y: 1}
--- !u!222 &3750459843292451767
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4681035672399457600}
m_CullTransparentMesh: 1
--- !u!114 &5108424620838132395
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4681035672399457600}
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: 1, g: 1, b: 1, 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: 10917, 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 &5785555120566224879
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4681035672399457600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ShowMaskGraphic: 0
--- !u!1 &4819045892542064047
GameObject:
m_ObjectHideFlags: 0
@ -11244,6 +11501,83 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &9036433839497035382
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3215173789656602693}
- component: {fileID: 8566176095083144866}
- component: {fileID: 2879485673068052520}
m_Layer: 5
m_Name: Content
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3215173789656602693
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9036433839497035382}
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:
- {fileID: 3011360593699687250}
m_Father: {fileID: 6335397886766934478}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &8566176095083144866
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9036433839497035382}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 0
m_StartCorner: 0
m_StartAxis: 1
m_CellSize: {x: 600, y: 733}
m_Spacing: {x: 0, y: 0}
m_Constraint: 2
m_ConstraintCount: 1
--- !u!114 &2879485673068052520
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9036433839497035382}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 2
--- !u!1001 &2540612749768456658
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -31066,6 +31066,10 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 362676243581000638, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0.00003915486
objectReference: {fileID: 0}
- target: {fileID: 1745005861961296864, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_AnchorMax.y
value: 0
@ -31162,6 +31166,18 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2562232161644998510, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2562232161644998510, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2562232161644998510, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3011360592396996928, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_Pivot.x
value: 0.5
@ -31586,6 +31602,10 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3011360593699687250, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3011360593759919820, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_AnchorMax.y
value: 0
@ -31618,6 +31638,10 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3011360593852809512, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 3011360593911696199, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_AnchorMax.y
value: 0
@ -31802,10 +31826,22 @@ PrefabInstance:
propertyPath: mygameObject
value:
objectReference: {fileID: 1553952863}
- target: {fileID: 6366530553166775013, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6366530553166775013, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7017397590614610888, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 346722530}
- target: {fileID: 8050182666048453755, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3}
--- !u!224 &366820005 stripped

View File

@ -0,0 +1,89 @@
using DG.Tweening;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
public class CheckpointsBox : MonoBehaviour
{
[Header("模式切换脚步")] public ModePanel _modePanel;
[Header("文字显示")] public Text _text;
[Header("旋转物品")] public GameObject OBJ;
private string temp;
// Start is called before the first frame update
void Start()
{
temp = _text.text;
_modePanel.mode1 += async () =>
{
_text.text = "";
await RotationObj(OBJ);
await TypeWriterEffect(temp);
};
_modePanel.mode2 += async () =>
{
_text.text = "";
await RotationObj(OBJ);
await TypeWriterEffect(temp + "(精英)");
};
}
// 让物体随机旋转,然后恢复到原来的位置
public async Task RotationObj(GameObject obj)
{
// 获取当前物体的旋转角度
Vector3 startRotation = obj.transform.rotation.eulerAngles;
// 随机生成一个旋转角度
float randomRotationY = Random.Range(-180f, 180f);
// 如果旋转角度的绝对值小于 60则强制设定为 60可以是正负60
if (Mathf.Abs(randomRotationY) < 120f)
{
randomRotationY = randomRotationY < 0 ? -120f : 120f;
}
// 使用 DOTween 来旋转物体,旋转到随机角度
await AnimateRotation(obj, randomRotationY);
// 动画完成后,旋转回 Y=0 的角度
await AnimateRotation(obj, 0f);
}
// 使用 TaskCompletionSource 来等待 DOTween 动画完成
private async Task AnimateRotation(GameObject obj, float targetYRotation)
{
// 获取当前物体的旋转角度
Vector3 startRotation = obj.transform.rotation.eulerAngles;
// 创建一个 TaskCompletionSource 来等待 DOTween 动画完成
var tcs = new TaskCompletionSource<bool>();
// 使用 DOTween 来旋转物体
obj.transform.DORotate(new Vector3(startRotation.x, targetYRotation, startRotation.z), 1f, RotateMode.FastBeyond360)
.OnComplete(() =>
{
// 动画完成后标记 Task 为完成
tcs.SetResult(true);
});
// 等待 Task 完成
await tcs.Task;
}
// 打字机效果
private async Task TypeWriterEffect(string text)
{
_text.text = "";
foreach (char c in text)
{
_text.text += c;
await Task.Delay(100); // 每个字符之间延迟100毫秒
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 36a154c6ab438304392f989d2d6ee437
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,11 +2,14 @@ using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using static TreeEditor.TreeEditorHelper;
public class ModePanel : MonoBehaviour
{
[Header("ģʽһ°´Å¥")] public Button btn1;
[Header("ģʽ¶þ°´Å¥")] public Button btn2;
@ -16,16 +19,24 @@ public class ModePanel : MonoBehaviour
public Color textColor1;
public Color textColor2;
public delegate void ModeChangeAction();
public event ModeChangeAction mode1;
public event ModeChangeAction mode2;
// Start is called before the first frame update
void Start()
{
btn1.onClick.AddListener(() =>
{
mode1?.Invoke();
MoveToTarget(obj, btn1.GetComponent<RectTransform>().position, speed * 100, btn2, btn1);
});
btn2.onClick.AddListener(() =>
{
mode2?.Invoke();
MoveToTarget(obj, btn2.GetComponent<RectTransform>().position, speed * 100, btn1, btn2);
});
}