public class communication
: MonoBehaviour
{
public Transform gamaOBj1
;
public Transform imsge
;
public Transform gamaOBj2
;
Vector3 gamaOBj1ViewportPoint
;
Vector3 gamaOBj2ViewportPoint
;
float image_x
;
float image_y
;
public Material satMaterial
;
public Camera Camera2
;
void Start()
{
}
void Update()
{
gamaOBj1ViewportPoint
= Camera2
.WorldToViewportPoint(gamaOBj1
.position
);
gamaOBj2ViewportPoint
= Camera2
.WorldToViewportPoint(gamaOBj2
.position
);
imsge_x
= imsge
.position
.x
/ Screen
.width
;
imsge_y
= imsge
.position
.y
/ Screen
.height
;
}
void OnPostRender()
{
if (!satMaterial
)
{
Debug
.LogError("请给材质资源赋值");
return;
}
satMaterial
.SetPass(0);
GL
.LoadOrtho();
GL
.Begin(GL
.LINES
);
GL
.Vertex3(imsge_x
, imsge_y
, 0);
GL
.Vertex3(gamaOBj1ViewportPoint
.x
, gamaOBj1ViewportPoint
.y
, 0);
GL
.Vertex3(imsge_x
, imsge_y
, 0);
GL
.Vertex3(gamaOBj2ViewportPoint
.x
, gamaOBj2ViewportPoint
.y
, 0);
GL
.End();
}
转载请注明原文地址: https://lol.8miu.com/read-29232.html