Skip to content

Best Approach for dynamic variables? #5

Answered by nijnstein
ruribev asked this question in Q&A
Discussion options

You must be logged in to vote

You can just use only the largest struct and cast to that as long as your base type is kept to float in the nativearray supplied and you dont access the fields not mapped (they will contain the next record which is very handy while debugging).

If you use a nativearray and fill the array with all data, then u could use a construct like:

((data1024*)&((float*)NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks())[ record_index * fieldcount ])->f1  (or [0].f1)

This is far from pretty though but wraps up nicely in a utilty function.

y

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@ruribev
Comment options

Answer selected by ruribev
Comment options

You must be logged in to vote
2 replies
@nijnstein
Comment options

@ruribev
Comment options

Comment options

You must be logged in to vote
1 reply
@nijnstein
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants