Enum is thought to be a float?

I keep running into this issue with Mono that my Enum is the wrong type and is expected to be a float?

I’m getting error CS1061- Type ‘float’ does not contain a definition for ‘smooth’… blah blah…

I get this statement if I try to use my enum in a switch statement and I haven’t a clue why. My other switch statement works fine but this one does not…

I’ve set up my enum like so outside my class.

public enum hoverSpeed {smooth, eightBit, appear}

I get a public reference in my class.

public hoverSpeed floatSpeed;

I then call this function that contains the switch statement →
speedType();

Here is the function.

public void speedType()
		{
			switch(floatSpeed)
			{
				case hoverSpeed.smooth:

					CompareTime.Value = 0.1f;

					break;
				case hoverSpeed.eightBit:

					CompareTime.Value = 0.5f;

					break;
				case hoverSpeed.appear:

					CompareTime.Value = 5f;

					break;
				default:

					CompareTime.Value = 0.1f;

					break;
			}
		}

and then I get the type error…

The error is gone if I use the global settings:

case global::hoverSpeed.smooth

but I want to know what I did wrong. And why I can’t use this enum like my other enum in my script? I’ve used multiple enums in a script before, the enums don’t share any similar names or variables. Why am I getting a type issue?

Either move the hoverSpeed enum into the class or do something like

using hoverSpeed = global::hoverSpeed;

at the top. Either of those should fix your problem, but I’m not entirely sure why you’d need to do that.

I’m not sure if it is better to delete my question or post my own answer but I figured out that the enum and a variable in the script were named the same thing so that caused this issue.