I am trying to add some data to the attribute parameters of below code in C# but every time it gives me the NullObjectRefrence exception. If anyone know about it please.
public class RootObject
{
public string description;
public string external_url;
public string image;
public string name;
public Attribute[] attributes;
}
[System.Serializable]
public class Attribute
{
public string trait_type;
public string value;
}
In The updatethePlayerData() function below i am trying to add the values of trait_type and its corresponding value.
public void updatethePlayerData()
{
RootObject rootObject = new RootObject();
rootObject.description = "aaa";
rootObject.image = "bbb";
rootObject.external_url = "ccc";
rootObject.name = "dddd";
rootObject.attributes[0].trait_type = "character_class";
rootObject.attributes[0].value = "name of cahracter";
}