Enum of float backing type

This is not compiling:

public enum MOTIONSCALES : float
        {
            NONE = 0.0f,
            REGULAR = 3.0f,
            STRONG = 10.0f
        }

The error is:
Assets/Scripts/CameraEffectsController.cs(830,17): error CS1008: Type byte, sbyte, short, ushort, int, uint, long or ulong expected

What am I doing wrong here?
Thanks.

Enums can’t be floats.

Probably you can just use a const float like so:

 const float NONE = 0.0f;
 const float REGULAR = 3.0f;

etc.

1 Like

Oh, I forgot about that. I guess the error is even telling me that. I got no sleep due to construction outside today.

1 Like

enum’s are intended for quick and easy named comparison

float’s aren’t intended to compare nicely (float error and all)

If you’re using this for comparison’s, I’d advise against it. If you needed representative values for easy access, then const’s are the way to go.

2 Likes

Since your float values are all whole numbers, you can use bits and cast to floats as needed.

But read what the others said about a better way.