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 pretender · Feb 23, 2011 at 07:39 PM · arrayobjectlistpool

object pool - how to use it / best practice

hi..i have a question about tracking the objects in the scene. i have a lot of objects in the scene, i would like to know what is the best practice to track their state

here is the example of what structure i have in the scene:

Root
    ObjectGroup1
           ObjectSubGroup1
           ObjectSubGroup2
    ObjectGroup2
           ObjectSubGroup1
           ObjectSubGroup2
    ObjectGroup3
           ObjectSubGroup1
           ObjectSubGroup2

every group and subgroup have meshes, colliders, etc... so far i was checking the state of the object and other things by getting the component that is attached to the script and reading the values. so every object have script attached to it, where i have values, for example transparent,hidden, value for alpha and other things...

is there a way to get the list of all objects and maintain their state in array. so every time i need to get the state or value that is specific for object i search for a name in the array and read its values?

can somebody point me in the right direction or provide examples, it would be appreciated.

thread at forums: http://forum.unity3d.com/threads/79266-object-pool

Comment
Add comment · Show 3
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 burnumd · Feb 23, 2011 at 08:20 PM 0
Share

Are these objects largely clones of each other?

avatar image pretender · Feb 24, 2011 at 11:59 AM 0
Share

no every object has unique name

avatar image burnumd · Mar 07, 2011 at 02:37 PM 0
Share

I mean, are they all being instantiated from the same prefab/GameObject? Are you looking for a way to query/change values on multiple scripts spread across many GameObjects? I'm just not sure what you're trying to do.

1 Reply

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

Answer by burnumd · Feb 23, 2011 at 08:42 PM

If I understand your question correctly, I'd probably differentiate them by GameObject name. You can change that as you create them in the Editor or when you instantiate them using Object.name, ie

//JS
var newObject = Instantiate (myObject);
newObject.name = newObject.name + " " + someUniqueId;

Then put them in a Dictionary

var myObjects : Dictionary.<string, GameObject> = Dictionary.<string, GameObject> ();

and when you instantiate them

var newObject = Instantiate (myObject);
newObject.name = newObject.name + " " + someUniqueId;
myObjects.Add (newObject.name, newObject);

Then you can access them by name with

myObjects[nameToCheck];
Comment
Add comment · 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 ina · Dec 19, 2011 at 03:44 AM 0
Share

Is Dictionary preferred over GameObject[] ?

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

1 Person is following this question.

avatar image

Related Questions

How to properly create a 2 dimensional array of an object. [C#] 1 Answer

How to remove objects from a list ? 3 Answers

A node in a childnode? 1 Answer

Convert Object[] to List 3 Answers

properly initializing my arrays (C#) 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