void OnPointCloudChanged(ARPointCloudUpdatedEventArgs eventArgs) { s_Vertices.Clear(); if (m_PointCloud.positions.HasValue) { foreach (var point in m_PointCloud.positions) { s_Vertices.Add(point); } } mesh.Clear(); mesh.SetVertices(s_Vertices); var indices = new int[s_Vertices.Count]; for (int i = 0; i < s_Vertices.Count; ++i) { indices[i] = i; } mesh.SetIndices(indices, MeshTopology.Points, 0); var meshFilter = GetComponent <MeshFilter>(); if (meshFilter != null) { meshFilter.sharedMesh = mesh; } }
void OnPointCloudChanged(ARPointCloudUpdatedEventArgs eventArgs) { var points = s_Vertices; points.Clear(); foreach (var point in m_PointCloud.positions) { s_Vertices.Add(point); } int numParticles = points.Count; if (m_Particles == null || m_Particles.Length < numParticles) { m_Particles = new ParticleSystem.Particle[numParticles]; } var color = m_ParticleSystem.main.startColor.color; var size = m_ParticleSystem.main.startSize.constant; for (int i = 0; i < numParticles; ++i) { m_Particles[i].startColor = color; m_Particles[i].startSize = size; m_Particles[i].position = points[i]; m_Particles[i].remainingLifetime = 1f; } // Remove any existing particles by setting remainingLifetime // to a negative value. for (int i = numParticles; i < m_NumParticles; ++i) { m_Particles[i].remainingLifetime = -1f; } m_ParticleSystem.SetParticles(m_Particles, Math.Max(numParticles, m_NumParticles)); m_NumParticles = numParticles; }