✅ `unexpected symbol switch` error
hello everyone. i hope you all are doing great. i got a problem here. i am getting this error in unity:
91 Replies
Pastebin
using System;using SBS.Math;using SBS.Racing;using UnityEngine;[Add...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
its line 132
can someone please help me?
thats the last error i need to fix for the project
afaik unity onlky supports up to c# 7.3, switch expressions were introduced in c# 8
oh i see. so how am i able to fix that switch error?
aaah, nvm, scratch that, u just have to edit the project file and raise the language version to at least 8
basically that
do i just have to type:
<LangVersion>7.3</LangVersion>
?well, its needs to be at least 8.0 as mentioned already
but yeah thats it
ok thx bro
9.0 seems to work as well (just checked one of my projects and since its autogenerated by unity i guess they support it, at least in version 2022)
uh just a quick question: where exactly do i have to add the
<LangVersion>7.3</LangVersion>
?
i mean which line?
if you know what i meandoesn't matter, as long as it's in a
<PropertyGroup>
which itself is in a <Project>
oh i see
thx
so i have it here
do i have to change the version to 8.0?
u have already 11 in there, that means switch expression should actually work and the issue lies somewhere else
but then i have no clue either
hmm ok
thx
which vs version r u using?
2022
hmm
i never figured it out
i think this will be a challenge
its just so hard to fix this
does anyone has an idea how to fix that?
don't use switch expressions?
yea but then i will get more errors
what?
that doesn't make sense
here removed the switch thing
that's not how that works, no
you need to convert the switch expression to some other way of returning the correct values
oh
i got it fixed
thank you so much bro
@just_ero ayo bro
how about here?
same error
wait let me send full code
Pastebin
using System;using System.Collections.Generic;using SBS.Core;using ...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
line 50
then ... use the same way to fix it and use a switch statement instead of a switch expression?
same way to fix it
oh right
thx guys
does anyone know what wrong here is?
i already tried
int hitInfo;
i still get errors when i do that
like thisPastebin
using System.Collections.Generic;using SBS.Core;using SBS.Math;usin...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
line 96
i tried everything i could
nothing worked
did u change the csproj file?
no
then something is wrong with ur IDE as it thinks the project is in c# 6, not in c# 11
(thats probably also the reason why the switch expressions earlier didnt work)
is it fixable?
i mean the error
i have no clue whats causing it so i dunno
ok thx
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.Couldn't fix it
It is too hard
But we are getting closer
The token thing is finished
Now there is another error
Here it is the
TrackBranch
I will send the link of the full code later
Since now i am not home
Yea it's herePastebin
using System.Collections.Generic;using SBS.Core;using SBS.Math;usin...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Line 98
hitInfo.token.TrackBranch
guys guys
i was stupid
i opened the wrong .cs file
with the langversion
@cap5lutSorry @alaa2003 your message contained blocked content and has been removed!
i was ret arded
i opened the wrong project file
this is the real one
well, then change the lang version
to which version
11?
or 8
9 is max it seems currently for unity
ok
so like i said before
i fixed the token thing
now there are 2 errors left
for the TrackBranch its:
'object' does not contain a definition for 'TrackBranch' and no accessible extension method 'TrackBranch' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?).
any idea how to fix this error?maybe
TrackBranch trackBranch = (TrackBranch)hitInfo.token.TrackBranch;
, but thats just guessingOk thx bro
note, that if
hitInfo.token.TrackBranch
is not a TrackBranch
it will throw a cast exception at runtimeIt is
(Maybe)
most probably
Okay bro I will try it out later
Thx again man
nope
still got the error
uh a question
how do i have to fix the switch thing here?
Yea give me a sec
My internet is fucked
A bit
here
like the other times, just instead of returning u set the variable (
_
is the default branch)ok thx bro
so would it be
switch (m_CarSettings.tractionAxle)
?yep
I tried it out yesterday I got too many errors
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.whats this?
the get_length
never got that error before
what to do here?
'Extensions.length.get' : cannot explicitly call operator or accessor
did u decompile some dll and try to make the resulting code working for ur game?
oh its just a game called
Motorway-Mayhem
it was an old police game from my childhood, but since the UnityPlayer got removed from browsers, i tried to make a standalone version of the game since some people asked me
i decompiled them
with ilSpy
or i just don't understand your question xdnah, u did answer my question
oh i see
but i doubt u r allowed to do this, so its against this servers rules and against discord's ToS, so i stop providing help here
oh
ok
just a quick question. why is it not allowed to decompile .dll files?
In the U.S., for example, copyright laws don't fully restrict decompilation. The Digital Millennium Copyright Act (DMCA) allows reverse-engineering, if a person has lawfully obtained a right to use a copy of a computer program, only to identify and analyze its elements to achieve interoperability with other programs. However, decompiling a program to circumvent a system that controls access to copyrighted work is considered illegal. Similarly, the EU also allows decompilation for some uses, including interoperability.u dont only want to interop, but u want to break copyrights and share it
oh i see
so i live in germany is it still not allowed?
in EU.
yep, its not allowed here either (im from germany as well)
oh i see
hmm
thats sad
ok then
thx again
also you won't help me even if i don't upload the game to public?
because i am the only one who will play it
my friends also know the game and who the developer is
i will send it to them and i will also credit the original creator
they will keep it private
but that doesn't change anything right?
yeah, that doesnt change anything
if u sit in the cinema recording what ya watch and give it ur friends and say "hey thats from pixar, dont give it to others" thats still piracy
yea
ok then
got it
well, as we cant help u further can u please $close this thread?
Use the
/close
command to mark a forum thread as answeredyea