Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by razivo · Mar 09, 2020 at 06:37 AM · switch-case

Unity not understanding tuples

my code is

 switch ((Coralator.BlockIn(MovmentToVector(), mov) != null), (Coralator.BlockIn(MovmentToVector(), mov).PartContainer.PartAttributeCheck(Part.PartAttribute.Unenterable) && !Coralator.BlockIn(MovmentToVector(), mov).PartContainer.PartAttributeCheck(Part.PartAttribute.Pushable)))
     {
         case (false, _):
             {
                 PartMov(mov);
                 break;
             }
         case (true, true):
             {
                 PartMov(mov);
                 break;
             }
         case (_, _):
             {
                 break;
             }
     }

and the c# compiler says it's fine and unity states that it has 14 errors. i tried adding a semicolon in the end and removing the curly brackets inside the cases. help?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by streeetwalker · Mar 09, 2020 at 07:14 AM

See this discussion: https://stackoverflow.com/questions/44355630/how-to-use-c-sharp-tuple-value-types-in-a-switch-statement/50768183

Comment
Add comment · Show 3 · 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 razivo · Mar 09, 2020 at 08:05 AM 0
Share

thanks, i tried it and it still didn't help, now it has 17 errors

 switch ((Coralator.BlockIn($$anonymous$$ovmentToVector(), mov) != null), (Coralator.BlockIn($$anonymous$$ovmentToVector(), mov).PartContainer.PartAttributeCheck(Part.PartAttribute.Unenterable) && !Coralator.BlockIn($$anonymous$$ovmentToVector(), mov).PartContainer.PartAttributeCheck(Part.PartAttribute.Pushable)))
         {
             case var t when t.Item1 == false:
                 {
                     Part$$anonymous$$ov(mov);
                     break;
                 }
             case var t when t==(true, true):
                 {
                     Part$$anonymous$$ov(mov);
                     break;
                 }
         }

can you help me?

avatar image streeetwalker razivo · Mar 09, 2020 at 10:38 AM 0
Share

Sorry, razivo! Without seeing all the relevant code and all the errors, there is now way to tell from here what possibly might be going wrong.

It looks like you are only checking 3 compound conditions. Why not write them as if else statements?

The fact that the compiler passes your original code indicates the problem is with the objects you're checking.

Null is always a bugger. One element of your tuple checks if the object is null, but if it is you are guaranteed to generate errors on any statements that deal the other element!

You'd be better off wrapping the whole thing in an if to make sure Coralator.BlockIn($$anonymous$$ovmentToVector(), mov) != null

avatar image razivo streeetwalker · Mar 09, 2020 at 02:26 PM 0
Share

thanks! the errors are not runtime errors, ins$$anonymous$$d they are compiler ones i.e. semi-colons and curly brackets. i decided to make it an if else statement, thanks!

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

200 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 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 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 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 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 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 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 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 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 avatar image avatar image

Related Questions

change object state using enum switch from another script 1 Answer

switch case statment 0 Answers

Determine Which Switch Case Was Called Last C# 1 Answer

Is there a better way to do connected textures for a tileset? 0 Answers

Can I access a Switch case from a Coroutine? 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