From 5e34df456e001df90660246dfa03f76bc7db33d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=92=E8=8D=A3=E6=A3=AE?= <7716842+shurongsen@user.noreply.gitee.com> Date: Tue, 26 Nov 2024 16:40:57 +0800 Subject: [PATCH] add --- .../Scripts/Conversion/DonatePanelItem.cs | 12 ++++++------ TheStrongestSnail/Assets/common/base/base.cs | 19 ++++++++++++++++++- .../Assets/prefabs/Convert2Panel.prefab | 1 + .../Assets/prefabs/Donate2Panel.prefab | 18 ++++-------------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/TheStrongestSnail/Assets/Scripts/Conversion/DonatePanelItem.cs b/TheStrongestSnail/Assets/Scripts/Conversion/DonatePanelItem.cs index 0b5d870..a60fac8 100644 --- a/TheStrongestSnail/Assets/Scripts/Conversion/DonatePanelItem.cs +++ b/TheStrongestSnail/Assets/Scripts/Conversion/DonatePanelItem.cs @@ -11,17 +11,17 @@ public class DonatePanelItem : BaseUIPanel public Text NumberOfFreeSnailShells; public Text Fees; public Text Total; - + public Button Button; void Start() { - Recipient.onValueChanged.AddListener((userInput) => GetInputData(userInput, Recipient)); - GiftQuantity.onValueChanged.AddListener((userInput) => GetInputData(userInput, GiftQuantity)); GiftQuantity.onValueChanged.AddListener(GiftQuantityData); - + Button.onClick.AddListener(buttonOnClick); + + testLogo(); } - void GetInputData(string userInput, TMP_InputField tmp) + void buttonOnClick() { - //ButtonClickAnimationAsync(tmp.gameObject,1.01f); + } async void GiftQuantityData(string userInput) { diff --git a/TheStrongestSnail/Assets/common/base/base.cs b/TheStrongestSnail/Assets/common/base/base.cs index dab3d29..25f8310 100644 --- a/TheStrongestSnail/Assets/common/base/base.cs +++ b/TheStrongestSnail/Assets/common/base/base.cs @@ -10,6 +10,15 @@ using UnityEngine.UI; public class Base : MonoBehaviour { public Button retbutton; + public GameObject ClosureObj; + private void Awake() + { + if (retbutton != null) + { + retbutton.onClick.AddListener(() => CancelOnClick(retbutton, ClosureObj)); + } + + } public async Task ButtonClickAnimationAsync(GameObject button,float max=1.25f)//按钮动画 { TaskCompletionSource tcs = new TaskCompletionSource(); @@ -64,9 +73,17 @@ public class Base : MonoBehaviour return regex.IsMatch(text); } - public async void CancelOnClick(Button button)//取消按钮 + public async void CancelOnClick(Button button,GameObject my_gameObject = null)//取消按钮 { await ButtonClickAnimationAsync(button.gameObject); + if (my_gameObject != null) + { + Destroy(my_gameObject); + return; + } Destroy(gameObject); } + + + } diff --git a/TheStrongestSnail/Assets/prefabs/Convert2Panel.prefab b/TheStrongestSnail/Assets/prefabs/Convert2Panel.prefab index a4c6d73..160ad7d 100644 --- a/TheStrongestSnail/Assets/prefabs/Convert2Panel.prefab +++ b/TheStrongestSnail/Assets/prefabs/Convert2Panel.prefab @@ -166,6 +166,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ee75c61d57c722e468ed4011fa66bea8, type: 3} m_Name: m_EditorClassIdentifier: + retbutton: {fileID: 0} Panel: {fileID: 158567709692854181} CloseBTN: {fileID: 0} inputField: {fileID: 6168167768698745100} diff --git a/TheStrongestSnail/Assets/prefabs/Donate2Panel.prefab b/TheStrongestSnail/Assets/prefabs/Donate2Panel.prefab index f4d3f26..a4efa44 100644 --- a/TheStrongestSnail/Assets/prefabs/Donate2Panel.prefab +++ b/TheStrongestSnail/Assets/prefabs/Donate2Panel.prefab @@ -121,19 +121,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 3410210057816977128} m_OnClick: m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 4509579862271681879} - m_TargetAssemblyTypeName: BaseUIPanel, Assembly-CSharp - m_MethodName: - 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_Calls: [] --- !u!1 &821927266036662165 GameObject: m_ObjectHideFlags: 0 @@ -1327,13 +1315,15 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 02ca8bd802049024389ac844292ef713, type: 3} m_Name: m_EditorClassIdentifier: - Panel: {fileID: 0} + retbutton: {fileID: 3568963963287766741} + Panel: {fileID: 4509579862240682304} CloseBTN: {fileID: 0} Recipient: {fileID: 5167839042553029366} GiftQuantity: {fileID: 8527512286296714387} NumberOfFreeSnailShells: {fileID: 4509579860519678074} Fees: {fileID: 8527512285347044353} Total: {fileID: 8527512286273835625} + Button: {fileID: 3364760182085171127} --- !u!1 &5167839042247917623 GameObject: m_ObjectHideFlags: 0