Spawn different enemies.

I have a custom class for the list

public List<Wave> WaveCount = new List<Wave>();

public class Wave
{
public GameObject EnemyPrefab;
public int EnemiesCount = 10;
public float spawnRate = 1;
}

thats all ok, I know how to do things with it, but now I want to do something like

public GameObject EnemyPrefab[];

and make for each prefab in the array EnemiesCount property. How?

You could do something like this. I think this is what you’re asking for.

public List<Wave> WaveCount = new List<Wave>();



public class Wave{

public GameObject EnemyPrefab;

public int EnemiesCount = 10;

public float spawnRate = 1;

}



Wave waveItem = new Wave();
WaveCount.Add( waveItem );

Edit:
Sorry, I think i misread what you wanted to do.
Basically you want a List of all the waves, and in each wave you want to create a set amount of enemies?

It’s looks like I need another list, with enemy prefab and count, or something like this… so I can make separate quantity for each prefab

Something like this, but maybe in more simple way?

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Test : MonoBehaviour 
{
	public List<Test1> T1 = new List<Test1>();

}

[System.Serializable]
public class Test1
{
	public List<Test2> T2 = new List<Test2>();
	public float thefloat;
}

[System.Serializable]
public class Test2
{
	public GameObject GO;
	public int i;
}

you can still use public GameObject[ ] EnemyPrefab;
for example public GameObject[ ] EnemyPrefab = new GameObject[10];
that will create spaces for 10 items in the array. Are you planning on adding the enemy prefabs by code or in the inspector?

The thing I’m trying to achieve is to add for each object in array personal number;

for example I have 2 gameobjects, and spawnCount for each of them

GO1 , GOcount
GO2 , GO2count - and so on…

Looks like List is the only way to do it

I’m going to have to assume some things here, since you didnt really answer the questions i asked in my 2 posts, but I think your second bit of code should work.
If you are using the inspector to add the EnemyPrefab, then you should probably just use the built in array instead of a list. But what you posted should work fine, unless there’s something I’m missing.

Yes, thats what I want

For each wave you are creating the same enemy type? or can there be multiple enemy types?

There should be different enemy types, prefabs assignment will be through inspector

Then something like this should work for your purposes.

// class that attaches to your GameObject
public class WaveSpawn : MonoBehaviour{
    
    public List<Wave> WaveCount = new List<Wave>();

}

 
[System.Serializable]
public class Wave

{

public Enemy[] EnemyPrefabs;

public int EnemiesCount = 10;

public float spawnRate = 1;

}


[System.Serializable]
public class Enemy{
   public GameObject enemyPrefab;
   public int id;
}