using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class click : MonoBehaviour
{
//public Color colorStart = Color.red;
//public Color colorEnd = Color.green;
public float duration = 1.0F;
public Renderer rend;
public bool WindowShow = false;
void Start()
{
//获取renderer组件
rend = GetComponent<Renderer>();
}
void OnGUI()
{
if (WindowShow)
GUI.Window(0, new Rect(30, 30, 200, 100), MyWindow, "Title");
}
//对话框函数;
void MyWindow(int WindowID)
{
GUILayout.Label("Content11111111111111111111111111111111111111111111111");
}
void OnMouseDown()
{
float lerp = Mathf.PingPong(Time.time, duration) / duration;
//这里就可以使用material来设置颜色了
rend.material.color = Color.Lerp(colorStart, colorEnd, lerp);
Debug.Log("show");
if (WindowShow)
WindowShow = false;
else
WindowShow = true;
}
}
刚开始学习unity,一些方法还不太熟悉,以后多学习