人物和摄像机之间存在例如墙壁等的阻挡时 可以修改阻挡材质的alpha呈现半透明状
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;
Renderer renderer = hit.collider.renderer;
if (renderer) {
renderer.material.shader = Shader.Find("Transparent/Diffuse");
renderer.material.color = new Color(renderer.material.color.r,
renderer.material.color.g,
renderer.material.color.b,
0.3F);
}
i++;
}
}
} 也可以像火炬之光那样 显示人物的透视效果