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 /
This question was closed Jun 22, 2014 at 09:52 PM by code-blep for the following reason:

Solved

avatar image
0
Question by code-blep · Jun 21, 2014 at 08:33 PM · gameobjectlistsort

Object Association in a List

Hi,

I have a List of GameObjects, some GameObjects are associated with other GameObjects and the association is stored as a List within the class.

I am trying to work out if there is a way to remove GameObjects from the list so that in the end there is only a list of GameObjects that are not associated with each other, while removing as few GameObjects as possible.

My thoughts are to start with the GameObject that has the most associations, and work on from there.

Here is an example of the GameObject associations:

GAMEOBJECT NUMBER [Other GameObjects Associated with this one]

GameObject1 [GameObject2, GameObject4, GameObject5, GameObject6]

GameObject2 [GameObject1, GameObject4]

GameObject3 [GameObject5, GameObject6]

GameObject4 [GameObject1, GameObject6]

GameObject5 [GameObject1, GameObject3]

GameObject6 [GameObject1, GameObject3, GameObject4]

GameObject7 [null]

Example of the List construction:

 var listOfGameObjects = List.<CollectionOfObjects>();
 
 class CollectionOfObjects
 {
     var thisGameObject : GameObject;
     var associatedGameObjects = List.<GameObject>();
     var totalNumberOfAssociations : int;
 }

Is this kind of sorting even possible? Thanks!

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 code-blep · Jun 22, 2014 at 09:52 PM 0
Share

Not to worry. Solved it in the end!

1 Reply

  • Sort: 
avatar image
0

Answer by Tanshaydar · Jun 21, 2014 at 08:52 PM

Unity is a Pattern Oriented.

I'd do that as follows.

1 - Create a script that will hold the list of GameObjects that will be associated with the object.

2 - Assign that script to the object and put game objects into that list.

3 - Create a controller object and assign it a controller script.

4 - In that controller script keep the list of objects with inner list of objects.

That would look like:

Controller Object[List Controller]

|-- Game Object 1[Object with associated objects 1]

|------Game Object 1a[Associated Object to 1]

|------Game Object 1b[Associated Object to 1]

|------Game Object 1c[Associated Object to 1]

|-- Game Object 2[Object with associated objects 2]

|------Game Object 2a[Associated Object to 2]

|------Game Object 2b[Associated Object to 2]

|------Game Object 2c[Associated Object to 2]

|-- Game Object 3[Object with associated objects 3]

|------Game Object 3a[Associated Object to 3]

|------Game Object 3b[Associated Object to 3]

|------Game Object 3c[Associated Object to 3]

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 code-blep · Jun 21, 2014 at 09:03 PM 0
Share

Sorry Tanshaydar but I don't see how that will give me a final list of dissociated GameObjects. Also I have a list like your suggestion already in place as show above. Thanks anyway :)

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

Sorting list of Transforms 1 Answer

How to add and sort a list of gameobjects by tag? 2 Answers

A node in a childnode? 1 Answer

Sorting a list of GameObjects by accessing their int values 2 Answers

Problem using IComparer to sort list of GameObjects 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