How to assign properties to GameObject's component

Hello!
Let’s say I have a lot of enemies in the scene. One enemy is a Snake, anotheris a Wolf etc.
Each enemy has component “EnemyStats” which has properties like Health, MaxHealth, Damage etc.

I also have a EnemiesList.cs where I keep a collection of enemies lets say sth like this:

Enemies.Add(new Enemy("Snake",2,3,5)))
Enemies.Add(new Enemy("Wolf",6,1,4)))
Enemies.Add(new Enemy("Monkey",2,3,2)))

At the Awake I want to assign to each Enemy GameoObject’s component “EnemyStats” its properties from the Collection.
What is the best way to do that?
For now, I came up with an idea of identyfing gameobject’s by its name.
I don’t know if that the best way since it compares strings…

Instead of dealing with names you can use Enum. e.g., define an enum:

Enum EnemyType
{
   Snake,
   Wolf,
   Monkey
}

and define a variable enemyType in Enemy class. Then use it like:

if(enemy.enemyType == EnemyType.Snake)
{
    // Set stats here
}

Hope it helps!

Hello!
An easy way would be to tag the enemies. Add the tag “enemy” to all your enemy gameobjects. Now you can get an array of all your tagged gameobjects any time you want:

GameObject[] enemies = GameObject.FindGameObjectsWithTag("enemy");

If you create your object by script you can store them in a List at the time of creation.

EDIT: ah, I obviously misunderstood your question. You want to assign different values depending on the type of the enemy (hope I understand now).

Even then you could be working with tags.

GameObject[] snakes = GameObject.FindGameObjectsWithTag("Snake");

Then loop over the objects and assign the correct value.