Search Unity

Feedback NativeArray/CollectionUnsafeUtility by ref/in Methods Change Request

Discussion in 'Scripting' started by LeCj, Mar 11, 2023.

  1. LeCj

    LeCj

    Joined:
    Dec 17, 2014
    Posts:
    3
    Hello,

    It seems unnecessary to pass big structs by copy, so I would like to suggest changing the NativeArray/CollectionUnsafeUtility API to support passing NativeArrays by ref. Similarly the NativeListUnsafeUtility class already has the GetInternalListDataPtrUnchecked<T>(ref NativeList<T>) method. It would be great to apply the same principle to all methods which accept native collections. Of course you would not be able to pass NativeArray fields marked with readonly by ref so by "in" or having the by ref methods as overloads could both be options. Let me know what you think.

    PS: Not sure if its better to post here or simply submit a bug report through the editor under the performance section. Please let me know!