Debug.Log()/Print()/UnityEngine.Debug.Log() 不起作用
我的项目正在使用 Oculus Quest 2 和虚拟现实。我正在编写一个脚本,该脚本应该检测手何时与游戏对象碰撞。该脚本无法正常工作,因此我尝试添加一些 Debug.Log() 语句来隔离问题,但它们不会打印到控制台。对这些问题的任何建议表示赞赏
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class colliderHit : MonoBehaviour
{
public GameObject myHand;
public GameObject menuItem;
public GameObject sublevel;
public GameObject topMenu;
Collider menuItemCollider;
Collider myHandCollider;
// Start is called before the first frame update
void Start()
{
if(menuItem != null)
{
menuItemCollider = menuItem.GetComponent<Collider>();
UnityEngine.Debug.Log("Menu Item not null");
}
else
{
print("Menu Item null");
}
if (myHand != null)
{
myHandCollider = myHand.GetComponent<Collider>();
}
else
{
Debug.Log("Hand Item null");
}
}
// Update is called once per frame
void Update()
{
if (myHandCollider.bounds.Intersects(menuItemCollider.bounds))
{
topMenu.SetActive(false);
sublevel.SetActive(true);
Debug.Log("Bounds intersecting");
}
}
}
My project is working with Oculus Quest 2 and Virtual Reality. I am writing a script that should detect when the hand collides with a game object. The script isn't working so I tried adding some Debug.Log() statements to isolate the problem but they don't print to the console. Any advice on these problems is appreciated
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class colliderHit : MonoBehaviour
{
public GameObject myHand;
public GameObject menuItem;
public GameObject sublevel;
public GameObject topMenu;
Collider menuItemCollider;
Collider myHandCollider;
// Start is called before the first frame update
void Start()
{
if(menuItem != null)
{
menuItemCollider = menuItem.GetComponent<Collider>();
UnityEngine.Debug.Log("Menu Item not null");
}
else
{
print("Menu Item null");
}
if (myHand != null)
{
myHandCollider = myHand.GetComponent<Collider>();
}
else
{
Debug.Log("Hand Item null");
}
}
// Update is called once per frame
void Update()
{
if (myHandCollider.bounds.Intersects(menuItemCollider.bounds))
{
topMenu.SetActive(false);
sublevel.SetActive(true);
Debug.Log("Bounds intersecting");
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您绝对确定没有禁用控制台日志中的消息吗?我问这个只是因为我也倾向于忘记这一点
Are you absolutely sure you didn't disable messages in the console log? I only ask this because I tend to forget about that as well