【发布时间】:2015-05-28 05:44:26
【问题描述】:
这是我的脚本:
var ctexture : Texture2D;
function Update() {
var ray = Camera.main.ScreenPointToRay (Vector3(Screen.width/2,Screen.height/2,0));
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
var pointVec=Camera.main.WorldToScreenPoint(hit.point);
GUI.Label(Rect(pointVec.x,pointVec.y,145,93),ctexture);
Debug.DrawRay (ray.origin, ray.direction * 10, Color.yellow);
Debug.Log(hit.point);}}
我可以看到 Debug.DrawRay 光线,这正是我想要的样子。问题是我看不到 GUI.Label 的结果。 ctexture 被分配,Debug.Log 打印出正确的信息。
提前致谢。
【问题讨论】:
-
这是在 OnGUI 函数中吗?我相信如果 GUI 调用不在正确的位置,它们将无济于事。在任何情况下,我都建议您使用新的 Unity UI 系统,而不是旧的和非常有限的遗留“GUI”系统。
标签: user-interface unity3d unityscript raycasting