Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Bafelmauk · Mar 18, 2017 at 08:41 PM · arraylistlistsarraylistlist of lists

wave list into list or( list into array)

Hello,

i have problem to make list into list.

i need because i have made so every wave have different monsters and i have multiple waves.

So i need list what contains my wave list like so : waves{wave1,wave2,wave3}

i have code that change wave 1 to wave 2

when i have wave[0] and its ended then i call wave[1].

is there way to make list in list ?

code is here :

         GameObject[] waveykskollid = { vastane1, vastane2, vastane2, vastane2 };
         wave1.AddRange(waveykskollid);
 
         GameObject[] wavekakskollid = { vastane3, vastane3, vastane3, vastane3 };
         wave2.AddRange(wavekakskollid);
 
         List[] waved = { wave1, wave2 };
         myList.AddRange(waved);
Comment
Add comment
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

3 Replies

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

Answer by RobAnthem · Mar 18, 2017 at 09:31 PM

You can always make an embedded list or multidimensional array.

 List<List<Wave>> waves;
 Wave[][] waves;
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 Bafelmauk · Mar 19, 2017 at 10:35 AM 0
Share

can you write some example how to do it ?

i'm not so skillful yet, i need some example code to understand it.

i searched on google but i didn't really get it, i tried few different ways but none of them worked.

i don't get how i can add 1 list into bigger list.

this code is in start():

     void Start() {
         StartCoroutine(SpawnWaves());
         GameObject[] waveykskollid = { vastane1, vastane2, vastane2, vastane2 };
         wave1.AddRange(waveykskollid);
         wave = wave1;
 
         GameObject[] wavekakskollid = { vastane3, vastane3, vastane3, vastane3 };
         wave2.AddRange(wavekakskollid);
         //List[] waved = { wave1, wave2 };
         //myList.AddRange(waved);
     }
avatar image
1

Answer by ExtinctSpecie · Mar 19, 2017 at 11:21 AM

 public class TestWave  
 {
 
     List<GameObject> minionsOfWave = new List<GameObject> ();
 
     public TestWave()
     {
         
     }
 
     public void AddMinion(GameObject minion)
     {
         minionsOfWave.Add (minion);
     }
     public List<GameObject> GetMinions()
     {
         return minionsOfWave;
     }
     public void PrintWave(List<GameObject> minions)
     {
         
     }
 
 }

 public class WaveManager : MonoBehaviour
 {
     List<TestWave> myWaves;
     TestWave wave;
 
 
     // populate these through inspector
     public List<GameObject> wave1;
     public List<GameObject> wave2;
 
     void Start()
     {        
         myWaves = new List<TestWave> ();
         CreateWaves (wave1);
         CreateWaves (wave2);
         PrintWaves ();
     }
     public void CreateWaves(List<GameObject> waveTemp)
     {
         wave = new TestWave ();
         foreach( GameObject minion in waveTemp)
         {
             wave.AddMinion (minion);
             print ("added minion to wave : " + minion.name);
         }
         myWaves.Add (wave);
     }
     public void PrintWaves()
     {
         foreach (TestWave wave in myWaves) 
         {
             int i=1;
                     foreach (GameObject minion in wave.GetMinions()) 
             {
                 print ("wave #: " + i + minion.name);
             }
         }
     }
 
 }

just some temporary code to give you a view of how you could achieve your goal

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 ExtinctSpecie · Mar 19, 2017 at 11:22 AM 0
Share

I forgot to increment I in the PrintWaves method i++;

avatar image
0

Answer by Bafelmauk · Mar 19, 2017 at 02:32 PM

i think you codes are too hard for me i'm really noob.

but i am thankful you responded my question it made me keep trying and it made me search different questions from google what i could not think on my own.

i got it work kinda how i needed but i don't know is it best way to do it.

i tried this code almost the same as yesterday but there was some sort of mistake in this code. I took some good night sleep and today it worked.

here is code that worked for me:

         List<List<GameObject>> wavedkokku = new List<List<GameObject>>();
         wavedkokku.Add(wave1);
         wavedkokku.Add(wave2);
         wave = wavedkokku[0];


thanks for replay!

Comment
Add comment · 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

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

75 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 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

How can you do calculations on two lists? 1 Answer

List of bools assigned to each Gameobject in List/Array 0 Answers

Problem with arrays in a list 1 Answer

How to prevent a list from being cleared at runtime? 2 Answers

Cache materials into List (or array) and restore from cached List? 0 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