12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using QFramework;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class ButtonEffect : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
- {
- public GameObject normailState, selectState, highlighterState;
- public void OnPointerEnter(PointerEventData eventData)
- {
- highlighterState.SetActive(true);
- normailState.SetActive(false);
- }
- public void OnPointerExit(PointerEventData eventData)
- {
- highlighterState.SetActive(false);
- normailState.SetActive(true);
- }
- float tmpTime = 0;
- public void Flashing(float time)
- {
- tmpTime += Time.deltaTime;
- if (tmpTime >= 0 && tmpTime <= 1)
- {
- SetLibraryBtnState(BtnState.highter);
- }
- else if (tmpTime > 1 && tmpTime <= 2)
- {
- SetLibraryBtnState(BtnState.normal);
- }
- else
- {
- tmpTime = 0;
- }
- }
- /// <summary>
- /// 设置工具库按钮状态
- /// </summary>
- /// <param name="select"></param>
- public void SetLibraryBtnState(BtnState state)
- {
- switch (state)
- {
- case BtnState.normal:
- normailState.SetActive(true);
- selectState.SetActive(false);
- highlighterState.SetActive(false);
- break;
- case BtnState.highter:
- normailState.SetActive(false);
- selectState.SetActive(false);
- highlighterState.SetActive(true);
- break;
- case BtnState.select:
- normailState.SetActive(false);
- selectState.SetActive(true);
- highlighterState.SetActive(false);
- break;
- default:
- break;
- }
- }
- }
|