I have a list and I want to assign its array to a property.
public void BuildMesh(List<Vector3> list){
mesh.vertices=list.ToArray();
}
Now the problems:
Do I have any option to prevent heap allocation?
EDIT: This is not a duplicate
Can't use IList<Vector3>
. The mesh is from a closed source API and needs Vector3[] so I can't assign IList<Vector3>
to it.
I think you're using Unity. If I'm right, try mesh.SetVertices(list)
which accept a List<Vector3>
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.