using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Update() {
RaycastHit[] hits;
hits = Physics.RaycastAll(transform.position, transform.forward, 100.0F);
int i = 0;
while (i < hits.Length) {
RaycastHit hit = hits[i];
Renderer renderer = hit.collider.renderer;
if (renderer) {
renderer.material.shader = Shader.Find("Transparent/Diffuse");
renderer.material.color.a = 0.3F;
}
i++;
}
}
}
网上看到的,很不错哦~~~~
转自博客园的:http://www.cnblogs.com/dosomething/archive/2012/04/03/2431149.html