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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

2D native array ?

Discussion in '2018.1 Beta' started by laurentlavigne, Jan 30, 2018.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,987
    Jobs are currently accessing static 2D arrays because I can't find a way to pass something like [int, NativeArray<float>. It works but I'd rather do it the job way, what are the native data types and what are they for?
     
  2. MartinGram

    MartinGram

    Unity Technologies

    Joined:
    Feb 24, 2017
    Posts:
    72
    I'm not sure I completely follow what you're asking for here.

    Can you give us some simple pseudo code examples of what you're trying to do and what you need?
     
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,987
    that's what I have, see how i use statics to access 2D array? I'd rather do it proper, how?
    Code (CSharp):
    1.     struct ComputeInfluenceJob : IJobParallelFor
    2.     {
    3.         public void Execute(int i)
    4.         {
    5.             for (int j = 0; j < instance.settings.Length; j++)
    6.             {
    7.                 //champandar
    8.                 int width = instance.size.x;
    9.                 int height = instance.size.y;
    10.  
    11.                 float minInf = 0, maxInf = 0;
    12.                 float inf = instance.emitterValues[j, i];
     
  4. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,613
    Use a 1D array and index it as array[y * width + x]? That's all that the 2D array is doing for you under the hood anyway.