12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- namespace SRF.UI
- {
- [AddComponentMenu("SRF/UI/Flash Graphic")]
- [ExecuteInEditMode]
- public class FlashGraphic : UIBehaviour, IEventSystemHandler, IPointerDownHandler, IPointerUpHandler
- {
- public void OnPointerDown(PointerEventData eventData)
- {
- this.Target.CrossFadeColor(this.FlashColor, 0f, true, true);
- }
- public void OnPointerUp(PointerEventData eventData)
- {
- this.Target.CrossFadeColor(this.DefaultColor, this.DecayTime, true, true);
- }
- protected override void OnEnable()
- {
- base.OnEnable();
- this.Target.CrossFadeColor(this.DefaultColor, 0f, true, true);
- }
- protected void Update()
- {
- }
- public void Flash()
- {
- this.Target.CrossFadeColor(this.FlashColor, 0f, true, true);
- this.Target.CrossFadeColor(this.DefaultColor, this.DecayTime, true, true);
- }
- public float DecayTime = 0.15f;
- public Color DefaultColor = new Color(1f, 1f, 1f, 0f);
- public Color FlashColor = Color.white;
- public Graphic Target;
- }
- }
|