Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class HandlerTestOnUI : MonoBehaviour, IPointerClickHandler {
Image image;
void Start(){
image = gameObject.GetComponent<Image>();
public void OnPointerClick(PointerEventData pointerData){
Debug.Log( + " がクリックされた!");
Color initColor = new Color(1.0f, 1.0f, 0.5f);
Color targetColor = new Color(0.5f, 1.0f, 0.5f);
StartCoroutine(ClickAnim(initColor, targetColor, 1.0f));
IEnumerator ClickAnim(Color initColor, Color targetColor, float processTime){
float finishTime = Time.time + processTime;
while (true){
float diff = finishTime - Time.time;
if (diff <= 0){
float rate = 1 - Mathf.Clamp01(diff / processTime);
image.color = Color.Lerp(initColor, targetColor, rate);
yield return null;
image.color = targetColor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.