我想在场景中的3D对象上添加UI按钮。我正在使用Hello AR场景。根据我的理解,3D对象拖入Hello AR Controller脚本(检查器)。我像往常一样添加画布和按钮。但是当我构建和运行时不起作用。目前我是开发ARCore增强现实应用程序的新手。谁能帮我?非常感谢!
UI按钮和APP示例都必须响应触摸输入:
if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId)) {
// .....
}
和:
if (Session.Raycast(touch.position.x, touch.position.y,
raycastFilter, out hit) && doPlace &&
!EventSystem.current.IsPointerOverGameObject(touch.fingerId)) {
var modelObject = Instantiate(ModelAndroidPrefab,
hit.Pose.position,
hit.Pose.rotation);
var anchor = hit.Trackable.CreateAnchor(hit.Pose);
modelObject.transform.LookAt(FirstPersonCamera.transform);
modelObject.transform.rotation = Quaternion.Euler(0.0f,
modelObject.transform.rotation.eulerAngles.y,
modelObject.transform.rotation.z);
modelObject.transform.parent = anchor.transform;
doPlace = false;
}
另外,我建议你观看Create ARFoundation application Udemy课程。
它可能是你的画布渲染模式,我建议你把它放在世界空间:
这可能是问题所在。