C
C#2y ago
MrPlayz24

❔ why isnt this code not highlighting as shown in yt

65 Replies
MrPlayz24
MrPlayz24OP2y ago
pls help anyone and the code dosent work to Picture 1*
Teuria
Teuria2y ago
have you installed a C# extension?
MrPlayz24
MrPlayz24OP2y ago
what u mean
Teuria
Teuria2y ago
oh wait
MrPlayz24
MrPlayz24OP2y ago
the code is done in Visual studio
Teuria
Teuria2y ago
alright, okie.. I just thought its vscode
MrPlayz24
MrPlayz24OP2y ago
no so also when i try to run code
Denis
Denis2y ago
Not sure whether it is applied implicitly, but shouldn't you have a namespace declaration at the top of the file?
MrPlayz24
MrPlayz24OP2y ago
hmm
Teuria
Teuria2y ago
you have a C# workload component installed? from the VS Installer?
MrPlayz24
MrPlayz24OP2y ago
i dont think so
Teuria
Teuria2y ago
that's probably why you wouldn't have a correct highlighting
MrPlayz24
MrPlayz24OP2y ago
but in youtube video they did not declare namespace but still worked does highlighting interfere with like when code is running?
Teuria
Teuria2y ago
nope actually, but it might help see you why the code is not running
MrPlayz24
MrPlayz24OP2y ago
oh
justaeris
justaeris2y ago
no it doesn't but if this means you don't have the C# workload, your code won't probably run
Teuria
Teuria2y ago
also, are you sure do you install them?
MrPlayz24
MrPlayz24OP2y ago
oh wait i thinl i did not install Game dev with unity
Teuria
Teuria2y ago
checks those what I check, and you'll be alright
MrPlayz24
MrPlayz24OP2y ago
wait how do i acess The workload page
Teuria
Teuria2y ago
goto Visual Studio Installer Modify and you will see the screen like this
MrPlayz24
MrPlayz24OP2y ago
got it
Teuria
Teuria2y ago
you also don't forget to check the .NET desktop development as well, you need that too, I think
MrPlayz24
MrPlayz24OP2y ago
i check it before
Teuria
Teuria2y ago
alright catcorn
MrPlayz24
MrPlayz24OP2y ago
im new to VS and C# so.. and Unity anyways thx guys
Teuria
Teuria2y ago
your welcome catpat
MrPlayz24
MrPlayz24OP2y ago
hmm it works but the highlighting did not apply
Teuria
Teuria2y ago
that's weird, but can you hover on the text (or some function) if it does gives an information? and also does errors also shows as well? it's just probably an editor visual bug
MrPlayz24
MrPlayz24OP2y ago
there is no visible error
Teuria
Teuria2y ago
erm, maybe restart the VS?
MrPlayz24
MrPlayz24OP2y ago
yes it does hmm ok
Thinker
Thinker2y ago
$unity
MrPlayz24
MrPlayz24OP2y ago
still dosent apply
Thinker
Thinker2y ago
wait nvm sorry
MrPlayz24
MrPlayz24OP2y ago
stays the same ive joined it already
Thinker
Thinker2y ago
$unityvs
Thinker
Thinker2y ago
I swear there was a tag for it
Teuria
Teuria2y ago
so, VS Unity workload shouldn't be installed right now?
Buddy
Buddy2y ago
$unitybug
MODiX
MODiX2y ago
If intellisense is not working for VSCode / Visual Studio, follow these steps.
Go into Unity Editor -> Preferences -> External Tools -> Set Visual Studio (or Visual Studio Code) as your preferred editor.
Go into Unity Editor -> Preferences -> External Tools -> Set Visual Studio (or Visual Studio Code) as your preferred editor.
Close the editor and re-open it again by double-clicking a script file.
Buddy
Buddy2y ago
This is the reason As Unity is dumb that it doesn't detect (and set) Visual Studio if VS is installed after Unity.
Teuria
Teuria2y ago
Unity being Unity
MrPlayz24
MrPlayz24OP2y ago
sheesh where is External tools
Buddy
Buddy2y ago
In Preferences Unity Editor itself
Buddy
Buddy2y ago
MrPlayz24
MrPlayz24OP2y ago
? oh so
MrPlayz24
MrPlayz24OP2y ago
MrPlayz24
MrPlayz24OP2y ago
should i click ti should i click regenrate project files i click it
Buddy
Buddy2y ago
no But you can try Sometimes that can also be it
Buddy
Buddy2y ago
But it should work if you have this set to whatever code editor you want to use
Buddy
Buddy2y ago
And then exit the editor then double-click a file in Project it should be highlighted.
MrPlayz24
MrPlayz24OP2y ago
hm so do i restart unity and vs wait it works thx anyways
MrPlayz24
MrPlayz24OP2y ago
MrPlayz24
MrPlayz24OP2y ago
was the code i did is in right way? like 4 if statements or can it be simplified
Thinker
Thinker2y ago
can't really be simplified
Teuria
Teuria2y ago
can still be simplified with Axis, but I think the current code is good for beginners
MrPlayz24
MrPlayz24OP2y ago
yea im a beginner so what project do you recommend i do 2d or 3d
Monsieur Wholesome
no, unity scripts are based on global classes
Buddy
Buddy2y ago
Use new Input System old one is absolutely shit If you want to play on a controller, you have to map the action for each control manufacturer (Xbox, Playstation) and so on.
MrPlayz24
MrPlayz24OP2y ago
Uh can you give an example please
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server