|
@@ -23,7 +23,8 @@ public class SB_EventSystem : MonoBehaviour
|
|
|
|
|
|
|
|
void Start() {
|
|
void Start() {
|
|
|
mouseTest = new MouseTest(this);
|
|
mouseTest = new MouseTest(this);
|
|
|
- InitListenerForMouseClickHightColor();
|
|
|
|
|
|
|
+ // InitListenerForMouseClickHightColor();
|
|
|
|
|
+ InitListenerForMouseHoverHightColor();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Update() {
|
|
void Update() {
|
|
@@ -34,23 +35,34 @@ public class SB_EventSystem : MonoBehaviour
|
|
|
[SerializeField] SimulateMouse simulateMouse;
|
|
[SerializeField] SimulateMouse simulateMouse;
|
|
|
|
|
|
|
|
#region 客户要求鼠标点到按钮时,按钮高亮
|
|
#region 客户要求鼠标点到按钮时,按钮高亮
|
|
|
- Graphic lockGraphic = null;
|
|
|
|
|
- Color pointerClickColor = Color.yellow;
|
|
|
|
|
- void InitListenerForMouseClickHightColor() {
|
|
|
|
|
- simulateMouse.OnPointerClick += (Selectable target) => {
|
|
|
|
|
- if (lockGraphic) return;
|
|
|
|
|
|
|
+ // Graphic lockGraphic = null;
|
|
|
|
|
+ // Color pointerClickColor = Color.yellow;
|
|
|
|
|
+ // void InitListenerForMouseClickHightColor() {
|
|
|
|
|
+ // simulateMouse.OnPointerClick += (Selectable target) => {
|
|
|
|
|
+ // if (lockGraphic) return;
|
|
|
|
|
+ // Button btn = target.GetComponent<Button>();
|
|
|
|
|
+ // if (btn.transition != Selectable.Transition.ColorTint) return;
|
|
|
|
|
+ // if (btn.targetGraphic) {
|
|
|
|
|
+ // Graphic graphic = btn.targetGraphic;
|
|
|
|
|
+ // lockGraphic = graphic;
|
|
|
|
|
+ // Color oldColor = graphic.color;
|
|
|
|
|
+ // graphic.color = pointerClickColor;
|
|
|
|
|
+ // DoTweenUtil.CallDelay(0.3f, () => {
|
|
|
|
|
+ // lockGraphic = null;
|
|
|
|
|
+ // graphic.color = oldColor;
|
|
|
|
|
+ // });
|
|
|
|
|
+ // }
|
|
|
|
|
+ // };
|
|
|
|
|
+ // }
|
|
|
|
|
+ Color pointerHoverColor = Color.yellow;
|
|
|
|
|
+ void InitListenerForMouseHoverHightColor() {
|
|
|
|
|
+ simulateMouse.OnPointerEnter += (Selectable target) => {
|
|
|
Button btn = target.GetComponent<Button>();
|
|
Button btn = target.GetComponent<Button>();
|
|
|
|
|
+ if (!btn) return;
|
|
|
if (btn.transition != Selectable.Transition.ColorTint) return;
|
|
if (btn.transition != Selectable.Transition.ColorTint) return;
|
|
|
- if (btn.targetGraphic) {
|
|
|
|
|
- Graphic graphic = btn.targetGraphic;
|
|
|
|
|
- lockGraphic = graphic;
|
|
|
|
|
- Color oldColor = graphic.color;
|
|
|
|
|
- graphic.color = pointerClickColor;
|
|
|
|
|
- DoTweenUtil.CallDelay(0.3f, () => {
|
|
|
|
|
- lockGraphic = null;
|
|
|
|
|
- graphic.color = oldColor;
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ColorBlock colorBlock = btn.colors;
|
|
|
|
|
+ colorBlock.highlightedColor = pointerHoverColor;
|
|
|
|
|
+ btn.colors = colorBlock;
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
#endregion
|
|
#endregion
|