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 Sisyphus · Mar 17, 2011 at 10:49 AM · instantiatearraygraphicsgridcube

Creating a grid of cubes.

Hi, sorry pretty new to Unity but I'll try to explain what I am trying to do.

I am trying to create a grid of 3d cubes, say 30 cubes * 50 cubes. Eventually I want to develop it so when the mouse moves over the a cube in the grid it rotates. But thats not the issue at the moment.

So my question is, simply is there an easy way to create a grid of cubes instead of doing it by hand manually?

Akin to the array tool in Cinema4D and in Actionscript 3:

public function CubeGrid(){

         var rowY:Number = 0;                    
         for (var i:int = 0; i < 190; i++) {
             var myCube = new CubeMenu(["//**//"],100);
             myCube.x = 0 + ((i % 10) * 200);
             if (i % 10 == 0) {
                 rowY += 200;
             }
             myCube.y = rowY;
             addChild(myCube);


         }

Thanks in advance.

*Mods if my Tags are wrong please amend.

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
3
Best Answer

Answer by Jesse Anders · Mar 17, 2011 at 12:40 PM

If you want to create the cubes via code, it would probably look something like what you've posted (i.e. a single or double loop, with a cube created for every iteration). I can't really think of any alternate approach that would be simpler or more straightforward than that.

You could also create the grid by hand in the editor pretty quickly by copying and pasting (e.g. create one row and copy-and-paste it N times). Or, you could write an editor script to create the grid, after which the cubes would be saved with the scene (meaning you wouldn't have to re-create them in code each time the level was loaded).

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

Adding Imperfections? 1 Answer

Grid matching issue 0 Answers

How to instantiate a prefab at mouse pos 1 Answer

Add instantiate object to GameObject[] 2 Answers

Instantiating cubes at runtime, align them 1 Answer


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