我需要向 ArCore 生成的每个网格添加一个网格碰撞器组件。但是,它返回此错误:“'MeshCollider' 是一种类型,在给定的上下文中无效。”
我尝试在 DetectedPlaneGenerator 脚本中添加该组件。这是代码:
namespace GoogleARCore.Examples.Common
{
using System.Collections.Generic;
using GoogleARCore;
using UnityEngine;
public class DetectedPlaneGenerator : MonoBehaviour
{
public GameObject DetectedPlanePrefab;
private List<DetectedPlane> m_NewPlanes = new List<DetectedPlane>();
public void Update()
{
// Check that motion tracking is tracking.
if (Session.Status != SessionStatus.Tracking)
{
return;
}
for (int i = 0; i < m_NewPlanes.Count; i++)
{
GameObject planeObject = Instantiate(DetectedPlanePrefab, Vector3.zero, Quaternion.identity, transform);
planeObject.GetComponent<DetectedPlaneVisualizer>().Initialize(m_NewPlanes[i]);
///Error here VVVVV
planeObject.AddComponent(MeshCollider);
}
}
}
}
MYYA
相关分类