how to use ‘class’ in programming c# with unity? 1. ‘class’ that we created ( example : public class PlayerData
in PlayerData.cs. 2. ‘class’ exist in unity class library ( example : UnityEngine.Sprite ). what different between using class ? how to understand it ? what i create a ‘class’.cs for? how it work? how to learn create a class file and use it? how to use class in unity class library?
hi;
i usually use them when i want a special kind of variables;
for example think that u want to create different charachters that have many different values like health , mana , armor etc …
to control them u have to create a variable for each soldier but with a class u can have all of the at once ;
[System.Serializable]
class SoldierVariables
{
public int Health;
public string Name;
public float moveSpeed;
public GameObject[] Guns;
}
and then simply create array of those variables like this to have in inspector :
public SoldierVariables[] AllSoldiersDetailes;
there are other uses too like create a functionality class to use later on other scripts and on but this is the most use i have from it ;