Hi, how do I change the values of my bool or some other variables in my Serializable?
[System.Serializable]
public class Skill{
public bool crash10;
public int atkCount;
}
public Skill[] allSkills;
I realize that when the variable is in Serializable, I can’t call it in the script itself.
You can change value of a serializable object the same way you do it for any other object. Marking a class with System.Serializable
attribute is just a way of telling Unity and .NET, that objects of this class can be serialized. This doesn’t cause any magic and your Skill class is still a normal class.
If you have an array of skills, and this array contains e.g. 2 elements, then to change crash10 variable in first element you just do:
allSkills[0].crash10 = true;