| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using FancyScrollView.FocusOn;
- using UnityEngine.Events;
- public class MouseButton : MonoBehaviour
- {
- [SerializeField] RectTransform targetRTF;
- [SerializeField] Graphic targetGraphic;
- [SerializeField] Color selectedColor = new Color(1, 1, 1, 0.6f);
- Vector3 _scale;
- Color _color;
- [SerializeField] public Button targetButton;
- [SerializeField] public GameObject cellObj;
- [SerializeField]
- UnityEvent OnStartEvent;
- [SerializeField]
- UnityEvent OnEndEvent;
- public void OnSelect() {
- if (targetGraphic) {
- _color = targetGraphic.color;
- targetGraphic.color = selectedColor;
- }
- if (targetRTF) {
- _scale = targetRTF.localScale;
- targetRTF.localScale = _scale * 1.15f;
- }
- if (targetButton) {
- targetButton.image.sprite = targetButton.spriteState.highlightedSprite;
- }
- if (cellObj) {
- cellObj.GetComponent<Cell>().onCellClickedEvent();
- }
- }
- public void OnExit() {
- if (targetGraphic) targetGraphic.color = _color;
- if (targetRTF) targetRTF.localScale = _scale;
- if (targetButton)
- {
- targetButton.image.sprite = targetButton.spriteState.disabledSprite;
- }
- //if (cellObj)
- //{
- // cellObj.SetActive(false);
- //}
- }
- public void OnSendStart() {
- OnStartEvent.Invoke();
- }
- public void OnSendEnd() {
- OnEndEvent.Invoke();
- }
- }
|