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 jamesflowerdew · Mar 21, 2014 at 02:37 PM · arraysvariablesgame objects

GameObject [,] variable will it be addresses?

I'm on the verge of creating a variable like this...


Public GameObject [,] Trees.


I want to place these objects in a 2D array to save distance calls etc, but am nagged by the possibility that each entry in this array could well contain everything within the gameobject, or just an "address" (link an integer and a type) to the point in the computer's memory.

Obviously the former would be madness and the latter would be ideal. Which is true, and is there an index somewhere showing what is stored for all unity specific variables?

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 suribe · Mar 21, 2014 at 02:58 PM 0
Share

With address, do you mean if what is stored is a reference to the object? Are you using C# or Javascript?

avatar image jamesflowerdew · Mar 21, 2014 at 03:01 PM 0
Share

c#

Yes, I just mean is it just a reference that's stored.

1 Reply

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

Answer by Wuzseen · Mar 21, 2014 at 03:06 PM

You would indeed have a list of references to gameobjects, not deep copies of everything that game object entails.

What do you mean what is stored?

http://docs.unity3d.com/Documentation/ScriptReference/GameObject.html

Tells you everything you need to know about what is inside a game object.

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 jamesflowerdew · Mar 21, 2014 at 03:09 PM 0
Share

I meant as in RA$$anonymous$$ impact more than anything. $$anonymous$$y code is way cleaner to the eye using direct references in a huge array, and runs faster, but worried I might get bitten by RA$$anonymous$$ further down the line.

avatar image Wuzseen · Mar 21, 2014 at 03:12 PM 0
Share

Since they're all references, it's the size of a pointer. So, it's very, very, $$anonymous$$imal. You will not get bit by RA$$anonymous$$ further down the line. These are just some of the joys of a 'modern' language. If you instantiate 100 game objects and store them in your array, you're just making references to them in the array, it's the same impact (potentially a bit more or less) as if you just made 100 GameObject variables.

avatar image jamesflowerdew · Mar 21, 2014 at 03:15 PM 0
Share

answer upvoted thx :)

avatar image Wuzseen · Mar 21, 2014 at 03:20 PM 0
Share

No problem!

(if you could accept it too that would be great!)

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

22 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

Related Questions

Object reference not set to an instance of an object 0 Answers

Sorting variable names by their values. 2 Answers

Locking the value of a variable, or something similar 2 Answers

Getting a variable from an object 1 Answer

How do variable arrays work? 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