Skip to main content

Chrome devtools throws an Enum parse exception error

Possibly due to the enum not containing the required value. Unity C# likely defaults to the first entry if a specific entry is not available in the enum and therefore does not show an error.

Possible solution:

  • Check your enum and ensure that all required fields are added. In Chrome devtools you can go to the line where the enum parse is happening and check what value is being checked. For example, here we are trying to parse ‘Enemy’ from Characters enum:

    (Characters)Enum.Parse(typeof(Characters), "Enemy"))

images-medium

For this to work, make sure that ‘Enemy’ is added in the your Enum like so:

```cs
public enum Characters {
Friend,
Enemy,
}
```