Http://www.cnblogs.com/dosomething/archive/2012/04/03/2431149.html
You can modify the alpha representation of a blocking material when there is a barrier between the character and the camera, such as a wall.
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 =
new
Color(renderer.material.color.r,
renderer.material.color.g,
renderer.material.color.b,
0.3F);
}
i++;
}
}
}
|
You can also show the perspective of a person like the light of a torch.
Draw occluded part ZTest Off, ZTest Greater
Draw the ZTest part of the mask on, ZTest lequal
Effect
X-ray effect of "Unity3d" Torch Light