❔ Why is there no color
Can i ask why some of my code isn't like turning blue or red or purple etc. Cuz i'm getting an error of void not being a valid token and im assuming this is the problem
16 Replies
What editor are you using?
ah
vs code
You need semicolons after
myRigidBody;
You need to end lines with a semicolon in C#oh mb i forgot that
but why doesn't void Start have no color?
because it thinks its a part of the lines above
also you can't do
public class RigidBody2D myRigidBody
oh
sorry i just got mixed up
oh there we go
it works now
youre calling it a class and not even having {} for the class bo dy
alright 👍
thanks
No problem
Btw it's generally recommended to use Visual Studio and not VSCode for Unity
The main issue seems to not be resolved by anybody, which is that you ened to configure your editor to work with Unity
Only then does it make sense to comment on code style and/or syntax errors, considering the editor does that for you
Steps to set up VSCode: https://code.visualstudio.com/docs/other/unity
Steps to set up VS2022: https://learn.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/getting-started-with-visual-studio-tools-for-unity?pivots=windows#install-unity-support-for-visual-studio
I would recommend you switch to VS2022 Community edition as VSCode is not properly supported, and will not be properly supported ever.
@bepool
Given that MonoBehaviour is coloured and recognized as a class, and the syntax highlighting only fails after the faulty syntax, I think it wasnt a problem to begin with
The editor would inform of the faulthy code, so it is in fact not properly configured.
I never understood how VSCode could be in a state where it recognises c# + Unity, but does not highlight syntax, but it in fact is a possibillity
One of the many reasons why I suggest VS2022 over VSCode
🤔
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.