Wanted to add a bit of what I found out, and which might be useful to other coding newbies.
The PathThe enums, like other definitions are stored away in a specific path, which is visible when you create the enum in the FSM, and when you set the Enum Type (which is "Days" in the example above). You can sort this neatly with a namespace. This is simply a bracket around everything, like this:
namespace Gameplay.Enum {
>enum days stuff here<
}
Gameplay.Enum and then the Enum variable is pretty much like a path like Gameplay/Enum/Days. You can call these any way you want, and create the path the way you want. This example will produce Gameplay > Enum > Days (nested twice) in Playmaker. Try this somewhere to get an idea.
It makes sense to do this, when you have several enums, and to keep a bit of order. You can also group your other scripts that way. Just put the namespace bracket around everything and it's sorted into the menu entry. However, you then also need to reference the path correctly. So when do this to your own NPCdata script, you can access it with Gameplay.NPCdata (Gameplay can be any name you want). Or Gameplay.Enum.Days etc.
You can also put it into a class. Classes have the same path structure, but don't produce a nested menu entry. Say, you have namespace Gameplay, then a class Enum, and then your stuff, you get again the menu Gameplay (as before), but this time, the specific enum looks like this "Enum+Days". So if you see strange errors, try to figure out the path, and it might fix it.
Enum in Data ScriptSee
MdotStrange's tutorial on simple data holder or interface scripts (there are a couple of good ones).
I found it confusing first and had lots of erros when I tried to add enums to my custom data holder scripts. But it is actually simple: Once, the enum is defined, you make use of it by treating it like a
custom variable type. Let's say you use the namespace snipped as I shown above (and no class) then all you need to do is place this in your variable list.
public Gameplay.Enum.Days currentDay;
I know, it looks weird for non-coders at first. But this is really the same principle as
public int myNumber. IN other words, Gameplay.Enum.Days is like your own variable type, and currentDay is the variable name in the current context. Once you place this in your script, you get a drop-down list with the enums in the editor. To get or set this to the Action, you simple refer to the variable like this
public FsmEnum currentDay; i.e. like all the other variables.
In other words. Somewhere (same file or another), you define the enum type(s). And once they exist in the Unity context, you can use them like your own variable types.
Changing EnumsBehind the scenes enums are integers (int), where in Jean's example Sunday is 0, Monday = 1 and so on. The names are simply counted. When you delete Wednesday (which was at the 4th position, with zero), then Thursday slips down from 4 to 3 internally and all your references are screwed up.
0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
when deleting Wednesday, becomes...
0 = Sunday
1 = Monday
2 = Tuesday
3 = Thursday
4 = Friday
Now 3 refers to Thursday and everything that referenced Wednesday now point at Thursday, everything that pointed at Thursday now points at Friday etc.It's thus better to not remove or add within the list (only to the end), merely replace. You can also
manually assign the ints to enums, by simply writing Sunday = 0, Monday = 1, etc. When you then delete or rearrange the list, the numbers stay the same, and are not reassigned.
Enums as FlagsLast thing. Enums can also be used as flags, which allows to assign multiple categories (instead of just one drop down list), say your character has multiple attack types, not just one. The keywords to search for is bitwise and enum flags.
Here's an article for this. There's are cheap assets that provide basic scripts on the Unity Store for this.
Hope this is useful for someone