# Referencing data in pre-defined array

**URL:** https://discussions.unity.com/t/referencing-data-in-pre-defined-array/29194
**Category:** Questions & Answers
**Created:** [September 29, 2011, 3:58am UTC](https://discussions.unity.com/t/referencing-data-in-pre-defined-array/29194 "2011-09-29T03:58:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![stereosound](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stereosound](https://discussions.unity.com/u/stereosound)
#### Post date: [September 29, 2011, 3:58am UTC](https://discussions.unity.com/t/referencing-data-in-pre-defined-array/29194/1 "2011-09-29T03:58:26Z")

</div>

So, I a game where it would be ideal to call up characteristics from a pre-defined list, such that if I have GameObject1, I can go to Array[1,2], Array[1,3], etc to pull out its characteristics.

That said, I do not know #1 how to do this (does unityscript have a 2d array function?) and #2 how I can save this information in say, the editor, so I don’t have a script in mono that is essentially unnecessary load times seeing as it would never change during runtime. Are there any solutions available in unity for this? Or if not, what is the best work-around?

---

<div class="post-metadata">

### Author: ![Julien-Lynge](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/julien-lynge/32/900731_2.png) [@Julien-Lynge](https://discussions.unity.com/u/Julien-Lynge)
#### Post date: [September 29, 2011, 5:17am UTC](https://discussions.unity.com/t/referencing-data-in-pre-defined-array/29194/2 "2011-09-29T05:17:01Z")

</div>

@stereosound

Unityscript supports regular Javascript arrays (according to [this](http://unity3d.com/support/documentation/ScriptReference/Array.html) page), so [here](http://www.kavoir.com/2009/02/javascript-multi-dimensional-array.html)’s how you’d set up the multidimensional array in code.

In order to save the data outside of runtime, you’d have to set up an editor script to collect the data and save it to disk (perhaps in an xml document in Resources) OR set up a custom EditorGUI that would allow you to enter the data as a series of one-dimensional arrays, or other equally exotic solutions.

That being said, if you’re really set on manually setting up the array from the editor you probably want to simply flatten the array to be one dimensional (and make sure it’s public) and then convert it to a 2d array at runtime (the cpu time to copy an array of pointers at runtime will be absolutely trivial, on the order of nanoseconds).
