Foods getFoodRandomFoodType() { string[] foodNames = Foods.GetNames(typeof(Foods)); //Debug.Log(string.Format("foodNames.Length = {0}", foodNames.Length)); int randIdx = Random.Range(0, foodNames.Length - 1); Foods ret = (Foods)System.Enum.Parse(typeof(Foods), foodNames[randIdx]); return(ret); }