Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by soft_sound · Apr 07, 2014 at 03:44 PM · errorfloatswitchenumcs1061

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by soft_sound · Apr 07, 2014 at 04:40 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by perchik · Apr 07, 2014 at 04:25 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

BCE0051 Error 1 Answer

error BCE0022: Cannot convert error, please help 3 Answers

Enum switch statement error 2 Answers

Enum and Variable with similar name resulting in error 1 Answer

Compiling error: AndroidJavaClass and AndroidJavaObject problems 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges