Loop Thru Enum Unity Code Example

Snippet 1
  const fruits = {
  apple: 28,
  orange: 17,
  pear: 54,
}

const keys = Object.keys(fruits)
console.log(keys) // [apple, orange, pear]
 
Snippet 2
  const fruits = {
  apple: 28,
  orange: 17,
  pear: 54,
}

const values = Object.values(fruits)
console.log(values) // [28, 17, 54]
 
Snippet 3
  public enum Days {
  Monday,
  Tuesday,
  Wednesday
}

foreach(Days day in Enum.GetValues(typeof(Days))) {
  
} 
Snippet 4
  for (auto const& i : data) {
    std::cout << i.name;
}