From ee945ee8d3199e91df76e7b320d2c37f5efc599a Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期三, 12 九月 2018 17:10:57 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
---
Utility/ComponentExtersion.cs | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/Utility/ComponentExtersion.cs b/Utility/ComponentExtersion.cs
index 618ef80..5877884 100644
--- a/Utility/ComponentExtersion.cs
+++ b/Utility/ComponentExtersion.cs
@@ -75,6 +75,17 @@
_button.onClick.RemoveAllListeners();
}
+ public static void SetListener(this Button button, UnityAction action)
+ {
+ if (button == null)
+ {
+ return;
+ }
+
+ button.onClick.RemoveAllListeners();
+ button.AddListener(action);
+ }
+
public static void AddListener(this Toggle _toggle, UnityAction<bool> _action)
{
if (_toggle == null)
@@ -82,6 +93,17 @@
return;
}
_toggle.onValueChanged.AddListener(_action);
+ }
+
+ public static void SetListener(this Toggle toggle, UnityAction<bool> action)
+ {
+ if (toggle == null)
+ {
+ return;
+ }
+
+ toggle.onValueChanged.RemoveAllListeners();
+ toggle.onValueChanged.AddListener(action);
}
public static void RemoveAllListeners(this Toggle _toggle)
@@ -102,6 +124,17 @@
_slider.onValueChanged.AddListener(_action);
}
+ public static void SetListener(this Slider slider, UnityAction<float> action)
+ {
+ if (slider == null)
+ {
+ return;
+ }
+
+ slider.onValueChanged.RemoveAllListeners();
+ slider.onValueChanged.AddListener(action);
+ }
+
public static void RemoveAllListeners(this Slider _slider)
{
if (_slider == null)
@@ -120,6 +153,17 @@
_inputField.onValueChanged.AddListener(_action);
}
+ public static void SetListener(this InputField inputField, UnityAction<string> action)
+ {
+ if (inputField == null)
+ {
+ return;
+ }
+
+ inputField.onValueChanged.RemoveAllListeners();
+ inputField.onValueChanged.AddListener(action);
+ }
+
public static void RemoveAllListeners(this InputField _inputField)
{
if (_inputField == null)
--
Gitblit v1.8.0