Задачу надо объяснять правильно:
using System;
using System.Collections.Generic;
using UnityEngine;
public class Character : MonoBehaviour
{
public CharacterClass characterClass = CharacterClass.Warrior;
public enum CharacterClass
{
Warrior,
Wizard
}
private List<CharacterClass> _classes = new List<CharacterClass>();
public void Start()
{
var names = Enum.GetNames(typeof(CharacterClass));
for (int i = 0; i < names.Length; i++)
{
_classes.Add((CharacterClass)Enum.Parse(typeof(CharacterClass), names[i]));
}
}
public void OnGUI()
{
GUILayout.BeginArea(new Rect(10, 10, 150, 300));
if (GUILayout.Button(characterClass.ToString()))
{
int index = _classes.IndexOf(characterClass) + 1;
if (index >= _classes.Count)
{
index = 0;
}
characterClass = _classes[index];
}
GUILayout.EndArea();
}
}