浏览代码

-Refactored PlaneClassification.cs to only subscribe to PlanesChanged

event once.
/3.1
Mike Durand 5 年前
当前提交
cfef1021
共有 1 个文件被更改,包括 15 次插入12 次删除
  1. 27
      Assets/Scripts/PlaneClassification.cs

27
Assets/Scripts/PlaneClassification.cs


void OnEnable()
{
m_ARPlaneManager.planesChanged += OnPlanesAdded;
m_ARPlaneManager.planesChanged += OnPlanesUpdated;
m_ARPlaneManager.planesChanged += OnPlanesRemoved;
m_ARPlaneManager.planesChanged += OnPlanesChanged;
m_ARPlaneManager.planesChanged -= OnPlanesAdded;
m_ARPlaneManager.planesChanged -= OnPlanesUpdated;
m_ARPlaneManager.planesChanged -= OnPlanesRemoved;
m_ARPlaneManager.planesChanged -= OnPlanesChanged;
}
void OnPlanesChanged(ARPlanesChangedEventArgs eventArgs)
{
OnPlanesAdded(eventArgs.added);
OnPlanesUpdated(eventArgs.updated);
OnPlanesRemoved(eventArgs.removed);
void OnPlanesAdded(ARPlanesChangedEventArgs eventArgs)
void OnPlanesAdded(List<ARPlane> addedPlanes)
foreach (var plane in eventArgs.added)
foreach (var plane in addedPlanes)
{
GameObject textObj = new GameObject();
textObj.transform.SetParent(plane.gameObject.transform, false);

}
}
void OnPlanesUpdated(ARPlanesChangedEventArgs eventArgs)
void OnPlanesUpdated(List<ARPlane> updatedPlanes)
foreach (var plane in eventArgs.updated)
foreach (var plane in updatedPlanes)
{
TextMesh planeText = plane.GetComponentInChildren<TextMesh>();
if (planeText)

}
}
void OnPlanesRemoved(ARPlanesChangedEventArgs eventArgs)
void OnPlanesRemoved(List<ARPlane> removedPlanes)
foreach (var plane in eventArgs.removed)
foreach (var plane in removedPlanes)
{
Component[] textMeshes;

正在加载...
取消
保存