#errors when using arrays in Scriptable object

1 messages · Page 1 of 1 (latest)

west fog
#

im having a very hard time trying to use an array in my scriptable object

[CreateAssetMenu(fileName = "CharacterDatabase", menuName = "Scriptable Objects/Character Database")]
public class CharacterDatabase : ScriptableObject
{
    [SerializeField]
    private Character[] characters;

    public int Count => characters.Length;

    public Character GetCharacter(int index)
    {
        return characters[index];
    }
}

[Serializable]
public class Character
{
    [field: SerializeField]
    public Sprite Sprite { get; set; }
    [field: SerializeField]
    public int Price { get; set; }
}
rare remnant
#

There is nothing wrong with the code you posted. It must be a problem with how you use it.

stray wasp
#

that is unity 6.2.5 and 6.2.6 problem, it works fine in 6.2.4

hard orbit
#

can you explain / show where you have a hard time using it ?