Collision使用 获取其组件执行变色操作

时间:2024-11-28 09:07:38
Collision使用 获取其组件执行变色操作using UnityEngine;
using System.Collections; public class CyCollision : MonoBehaviour { void OnCollisionEnter(Collision other)
{
// Debug.Log ("Enter");
// Debug.Log(other.collider);
other.collider.GetComponent<MeshRenderer>().
material.color = Color.green;
} void OnCollisionStay(Collision other)
{
// Debug.Log ("Stay");
} void OnCollisionExit(Collision other)
{
// Debug.Log ("Exit");
other.collider.GetComponent<MeshRenderer>().
material.color = Color.red;
}
}