using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Ontriggle : MonoBehaviour {
List<Color> colorlist;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
colorlist=new List<Color>();
for(int i=0;i<other.renderer.materials.Length;i++)
{
colorlist.Add(other.renderer.materials[i].color);
other.renderer.materials[i].color=Color.red;
}
}
void OnTriggerStay(Collider other)
{
Debug.Log ("-------stay----");
}
void OnTriggerExit(Collider other)
{
for(int i=0;i<other.renderer.materials.Length;i++)
{
other.renderer.materials[i].color=colorlist[i];
}
}
}
unity OnTrigger和List使用
最新推荐文章于 2024-06-14 08:50:22 发布