Search Unity

[Job System] Buffer pointer and native array resize

Discussion in 'C# Job System' started by iBicha, Mar 12, 2018.

  1. iBicha

    iBicha

    Joined:
    Jul 7, 2013
    Posts:
    30
    Request: please expose the buffer pointer of a native array. we might want to do some manipulations that would be faster with pointers.

    Also, please allow the resizing the a native array, and most importantly, do it using `UnsafeUtility.Realloc` which might by change allow the expansion of the memory without reallocation and copying from the old pointer.
    Thanks.
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Check out Unity.Collections.LowLevel.Unsafe
     
    iBicha likes this.
  3. iBicha

    iBicha

    Joined:
    Jul 7, 2013
    Posts:
    30
    Thanks for the pointer! (pun not intended)
    I still don't see where resizing could happen (or if it's possible at all)
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    NativeArray doesn't support resizing. You can use NativeList for that purpose.
     
    iBicha likes this.
  5. iBicha

    iBicha

    Joined:
    Jul 7, 2013
    Posts:
    30
    I can't find it, maybe it's not shipped yet in the latest beta?
    I guess another option would be to have A NativeArray that is large enough, And use NativeSlice whenever it is needed to use smaller portions of it
     
  6. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    It is included with the ECS. You need to install that package
     
    iBicha likes this.