Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Clonkex · May 30, 2015 at 04:05 AM · javascriptarraylistsmultidimensional array

How to Create Dynamic Multidimensional Array?

I need to create a 3D array that can be resized per-dimension. My first thought was to create a 1D array and "simulate" the 3D array (like thing[(height*y)+x] or whatever it is) but I don't believe that would allow for resizing. I googled it but all I could find was how to make static multidimensional arrays.

How would I achieve this in JavaScript/UnityScript?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Benjames · May 30, 2015 at 06:24 AM

I know with c# you can create Lists that allow for resizing.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benjames · May 30, 2015 at 06:25 AM 0
Share

http://stackoverflow.com/questions/10115769/something-similar-to-c-sharp-net-generic-list-in-java

Ya java has lists google "c# list java equivalent" :))

avatar image Clonkex · May 30, 2015 at 06:29 AM 0
Share

@Benjames Well yeah, I know I can create Lists (this is most useful page ever) but that doesn't help me. I need to create a multidimensional array and don't know how.

avatar image Benjames · May 30, 2015 at 06:00 PM 0
Share

So I believe you can make a multidimensional array like this:

 var mda=new float[300,50,300];

to re size you would probably have to make a new array and just transfer the values

I suggested Lists because they can be re sized, although it might be tough to make a multidimensional list.

http://stackoverflow.com/questions/4401850/how-to-create-a-multidimensional-arraylist-in-java

You could make a class with three separate Lists.

 class md
 {
     List<float> x;
     List<float> y;
     List<float> z;
 }

so when you're adrressing it you would be like md.x or md.z that type thing

Sorry I couldn't help more.

avatar image Clonkex · May 31, 2015 at 12:35 AM 0
Share

@Benjames The fact that it's tough to make a multidimensional list is why I posted the question. Also, your second code-box wouldn't work. Each subsequent array needs to be contained within the last.

I did attempt to create a multidimensional List like this:

 var room:List.<List.<List.<roomInfo> > >;
 
 room=new List.<List.<List.<roomInfo> > >();
 room.Add(new List.<List.<roomInfo> >());
 room[0].Add(new List.<roomInfo>());
 room[0][0].Add(new roomInfo());

As you can see that's pretty confusing already, but then try resizing the array without making it jagged... there has to be a better way...

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multidimensional array variable size (JS) 1 Answer

Array - insert item in the middle 1 Answer

Error creating 5-dimensional array 1 Answer

How to Create Multidimensional Array in Javascript? 1 Answer

How to Add Elements to Size-Undefined Multidimensional Array in Javascript? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges