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 SwiftRocket · Dec 14, 2014 at 07:28 PM · gameobjecteditorarray

How to drag in gameObject to public gameObject array property

This is probably a silly question, but how am i supposed to drag in a game object to a public game object array in the Unity editor????

I really can't figure it out

Array in editor

When i try to change size, it just changes back to 0

public variable declaration:

 public GameObject[] Hazards;

Little video

Please help. thanks

hazards.png (1.5 kB)
Comment
Add comment · Show 1
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 EvilTak · Dec 15, 2014 at 01:02 AM 0
Share

Drag it to the name of the array, and the cursor will have a little plus sign on it. It will automatically add the index and the gameobject. You can do this with multiple objects if order doesn't matter.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by justin35f · Dec 15, 2014 at 01:14 AM

An array needs it's size initialized before it can be used. What you can do is click into the size property where the 0 is and change it to however large you need. If you are having an issue doing this, make sure you press enter after you change it. Sometimes the editor is a bit finicky and resets a value if you don't press enter.

Once you change the size, you'll see several slots open up below (the same number as you just typed in) and you can then drag your object into those slots.

Comment
Add comment · Show 3 · 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 Eric5h5 · Dec 15, 2014 at 01:20 AM 1
Share

You don't need to do this; you can just drag an item (or multiple items) onto the array name. Unity will add the items to the array automatically, and the number will change to reflect how many items are in the array.

avatar image justin35f · Dec 15, 2014 at 07:08 AM 0
Share

Yes, I understand that it is possible to drag directly onto the name. If you watch the video, that isn't working though, so I offered an alternate solution.

avatar image SwiftRocket · Dec 15, 2014 at 01:28 PM 0
Share

This solution worked, and i also discovered that the problem was because of my prefab :) (because Unity crashed a little while before) . i can't drag it in the scene or slots anymore. but that's no problem. i'll fix that. THAN$$anonymous$$S!

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

Can a GameObject inside of an array be made "accessible" from the editor? 2 Answers

Unload from memory - GameObject in an array? 1 Answer

How to set to game objects's position from 2 different game objects arrays equal to each other? 0 Answers

How would you override Editor object dragging? 0 Answers

Any way to lock an object from changes in the editor? 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