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;
    }
}

 

posted @ 2016-10-29 15:38  扎北强子  阅读(235)  评论(0编辑  收藏  举报