• 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 /
  • Help Room /
avatar image
Question by polda602 · Apr 13, 2016 at 05:42 PM · transformarraylistarraysarraylist

Array problem, I'm novice

`Hi, I'm trying to make array, I have a transform in game and I want to make array with my prefabs and then when I press button, these prefabs will create as c$$anonymous$$ld of the my transform. Please post sample code. Thank you. I tried somet$$anonymous$$ng but it didn't work. I was looking at unity scripts, but I don't understand how can I make what I want.

 public GameObject[] videos;
     public int numberOfVideos = 5;
 
     public string nameOfVideo;
 
 
     public GameObject video;
 
     // Use t$$anonymous$$s for initialization
     void Start () {
         rs = GetComponent<RecordingSys> ();
         videos = new GameObject[numberOfVideos];
     }
     
     // Update is called once per frame
     void Update () {
         for (int i = 0; i < numberOfVideos; i++) {
             GameObject go = Instantiate (video, new Vector3 ((float)i, 1, 0), Quaternion.identity) as GameObject;
             go.transform.localScale = Vector3.one;
             go.transform.parent = GameObject.Find ("VideoPanel2").transform;
             videos[i] = go;
         }

Comment

People who like this

0 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 Eno-Khaon · Apr 13, 2016 at 05:50 PM 1
Share

You tried something, but it didn't work; what did you try?

I'm not asking to be mean or anything. Each person has their own approach to solving a problem, so if you can show us what your approach was, it can give others an idea of how a solution can be presented in a way which improves your understanding as a whole.

Getting a solution from others, especially when considering yourself to be a "novice" can easily get you thinking that there aren't other or better solutions to the problem.

The most important thing to do is to improve on your own understanding of the implementation. Right now, one of the best ways you can do that is to show us where you stand so we can help push you in the direction you need to go.

avatar image polda602 Eno-Khaon · Apr 13, 2016 at 05:52 PM 0
Share

There is the problem, the prefab is creating in infinite times. I just want make for example 5 video objects at my parent transform.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by gjf · Apr 13, 2016 at 06:01 PM

it's because you're creating them in Update() - that runs EVERY frame... if you want them to be created at the start, put the code in Start()

Comment
Chronovore

People who like this

1 Show 1 · 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 polda602 · Apr 13, 2016 at 07:37 PM 0
Share

Thanks, that was it !

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

48 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Moving spawned enemies randomly towards several pre-defined positions 1 Answer

Getting the element that has the same element number on another list ? 2 Answers

Drag and Drop. Grid Array to save if something is placed not working. Fix?,Drag and Drop Grid array to save the positions of placed Object not working. Fix? 1 Answer

I have trouble understanding arrays and enums. When and how? 0 Answers

only keep every 10th entry in an array? 2 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