Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved NativeSlice use case

Discussion in 'DOTS Dev Blitz Day 2023 - Q&A' started by optimise, Aug 24, 2023.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,029
    Actually what's use case for NativeSlice? Until now I still not sure how to use it and where it can be useful
     
  2. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    228
    I wouldn't, probably. It's super old and not very fast because it has to consider stride and stuff.
     
  3. barbara-wang

    barbara-wang

    Unity Technologies

    Joined:
    Jul 17, 2020
    Posts:
    5
    We intend to obsolete NativeSlice and advise against its usage. The primary driver behind this decision is that indexing with NativeSlice is slow. Instead, we suggest exploring alternative methods to extract portions of data using stride or aliasing tailored to the specific use case. For example, consider aliasing a NativeArray to get parts of its data, NativeArray.GetSubArray().
     
    Last edited: Aug 24, 2023
    msfredb7 and HBG-Mathieu like this.