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 dylan92 · Mar 27, 2012 at 05:25 PM · instantiateprefabsgameobjects

Instantiating Multiple Prefabs at Runtime

So I found some code to create a floor out of cube objects and I am trying to adapt this code to use GameObjects instead. I have created a Cube GameObject and added a texture to it, which is in my Project window. I dragged this Cube onto my Block prefab which was empty. Then I created an empty GameObject and placed it in the Hierarchy window. I added my Initialize script to this empty GameObject. Here is the code:

 //Creates the floor of the world
 var min = -25;
 var max = 25;
 var block : GameObject;
 
 function start() {
      for (var y = min; y < max; ++y) {
         for (var x = min; x < max; ++x) {        
             var newBlock = Instantiate(block, Vector3(x,0,y), Quaternion.identity); 
             newBlock.transform.position = transform.position + Vector3(x, 0, y);
         }
     }
 }

In the Hierarchy window I clicked on the GameObject with this script attached and assigned the block variable to my Block prefab. This code should make a 25x25 square of blocks, but instead none of the blocks are spawning. I'm pretty sure the code is right but I'm not sure why nothing is happening. Any help would be greatly appreciated.

Comment
Add comment · Show 2
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 by0log1c · Mar 27, 2012 at 05:34 PM 2
Share

Just making sure this is just a typo, your code is using Start() and not start() right? The capitalization is important.

avatar image dylan92 · Mar 27, 2012 at 05:36 PM 0
Share

Wow. That was it. Not sure how I missed that. Thank you!

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Tracking instantiated objects 1 Answer

Make a game object in a scene into a prefab with script 1 Answer

changing scene vs. instantiated prefabs 1 Answer

Instantiate an object in a prefab? 1 Answer

How to destroy an instantiated prefab in C#? 4 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