x


Accessing data in an array of arrays

I have an array of arrays. I am wondering

 // why does this work 

Debug.Log("woodPriceArray[whichRes] = " + woodPriceArray[whichRes]);

Debug.Log("priceArrays[1][1] = " + priceArrays[1][1]);

// and not this, which is essentially the same thing ( n o t e : whichRes =1 )

var randVar : int = 1;

Debug.Log("LOOK HERE 1: " + quantityArray[whichRes][randVar]);

more ▼

asked May 02, 2012 at 11:54 AM

littlemegzz gravatar image

littlemegzz
11 16 12 13

woodPriceArray is set to quantityArray[1]

priceArrays[1][1] gives the same result as woodPriceArray[1]

May 02, 2012 at 11:56 AM littlemegzz
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I'm not sure if this is currently accurate, but I've had difficulty in the past, and never actually figured out back then, how to get multi-dimensional arrays working in javascript. They will definitely work with c# though..

EDIT:

turns out, as suspected my info was outdated.. here's a link that may start you down the right track:

http://answers.unity3d.com/questions/11963/how-to-create-multidimensional-arrays-in-javascrip.html

looks like it's: QuantityArray[1,1]

more ▼

answered May 02, 2012 at 11:58 AM

Seth Bergman gravatar image

Seth Bergman
8.6k 34 35 57

ok, thanks for the quick reply. I dont know c# so that wont help me just now... hmmmm

May 02, 2012 at 11:59 AM littlemegzz

Does anyone else know whether this is just some unity javascript thing?

May 02, 2012 at 12:03 PM littlemegzz

see answer above, you would say it as: quantityArray[1,1] etc..

May 02, 2012 at 12:15 PM Seth Bergman
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x703
x30

asked: May 02, 2012 at 11:54 AM

Seen: 1241 times

Last Updated: May 02, 2012 at 11:31 PM