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 Arrays, Where Fore Art Thou?

Discussion in 'Scripting' started by renman3000, Oct 24, 2018.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    Why doesn't Unity natively support, 2DArrays in the inspector?
    Seriously?
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    Good question.

    There is a workaround though; you could make an array of a class that holds multiple data types:
    Code (CSharp):
    1. public class SomeClass : MonoBehavior {
    2.    public FakeMDArray[] fakeMdArray;
    3. }
    4.  
    5. [System.Serializable]
    6. public class FakeMDArray {
    7.    public int value1;
    8.    public int value2;
    9.  
    10.    //etc...
    11. }
     
  3. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    Further, after getting it working, (via creatig my own editor scripts, property class etc), if I add in two 2D Arrays, my inspector looks like this.

    Really Unity??

     
  4. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    Also this.....
    Very handy.
     
  5. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,732
    I'm pretty sure you're discovering why 2D arrays don't have inspector support. Once they go past a certain (very small) set of dimensions, they become totally unmanageable.
     
    Kiwasi likes this.
  6. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    I could have a single array of 100000000000000. Thats kinda unmanageable....

    I suppose you have a point, but still.
     
  7. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,732
    Yeah, 100,000,000,000,000 long.

    Not wide.

    Long.
     
  8. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    It would seem to me you simply haven't got the code set up right. Its possible to draw the inspector to whatever height you desire.

    I tend to edit my 2D arrays in 3rd party software. Excel does well for numerical or text data. Its easy to save/load a csv. Paint or Photoshop does well for things like map data. An image is essentially a 2D array, and Unity is pretty good at reading data out of an image file.