I have a list of enums. I want to add a new item to it without scripting to make them more easily modifiable for game designers. I made an inventory system and I want to define the type of an item. For an example apple is a type of food and stone is a type of object.
Is there a way to group these items in the inspector?
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public const string[] typesStrings = {"Player", "Prop", "Enemy"};
[System.Serializable]
public class TypeList
{
public enum types
{
PLAYER = 0,
PROP = 1,
ENEMY = 2
}
};
// MonoBehaviour class
public TypeList.types selectedType;
public void Start()
{
string selected = TypeList.typesStrings[(int)selectedType];
}
}
This, however, gives me the following error:
Assets/grouping.cs(5,31): error CS0134: A constant
grouping.typesStrings' of reference type
string[]' can only be initialized with null
static readonly
which is not quite constant (the array contents are still mutable) but close enough for my purposes. \$\endgroup\$