Support converting byte arrays to Unity struct arrays in Udon
ureishi
I would like to request support for efficiently converting byte[] data into Unity struct arrays in Udon, such as:
Color[]
, Color32[]
, Vector2[]
, Vector3[]
, Vector4[]
Ideally, this would be similar in spirit to
System.Buffer
, but extended to support Unity struct arrays.## Background
Currently, converting raw byte[] data into Unity struct arrays in Udon is not straightforward.
While it is technically possible through indirect approaches, these require many Udon steps and become inefficient when handling large datasets.
In an actual 3D model loader currently in use, this process may need to handle hundreds of thousands of elements, such as around 300,000 entries.
## Proposal
Please add a way for Udon to convert byte[] data into Unity struct arrays, similar in spirit to
System.Buffer
.For example:
Vector3[] vertices = new Vector3[size];
UdonBuffer.TryBlockCopy(byteData, byteIndex, vertices);
This would make it possible to directly convert binary data obtained from external sources (such as data fetched from the web) into Unity struct arrays in Udon, without workarounds.
Log In