question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code wrapped in defines not highlighting correctly with Unity

See original GitHub issue

Environment data

VS Code version: 1.26 C# Extension version: 1.15.2 Unity version: 2017.3.1f1 .Net3.5 OS: Windows 10

Steps to reproduce

  1. Create unity project
  2. Create code with defined out code Ex. #if UNITY_ANDROID

Expected behavior

Code that is not being compiled due to defines should be grayed out

Actual behavior

Code looks normal or has incorrect highlighting. In the screenshot below the highlighting at the top is reversed because the RECORD_RAND_FLOAT_CALLS is not defined. Hovering works as expected with the defined out code not giving any results. You can also see towards the bottom that another #if #else has different behavior with the same define. image 3

I’ve also looked at the Assembly-CSharp.csproj file and confirmed that it does contain a UNITY_ANDROID define but highlighting does not occur.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JoeRobichcommented, Apr 19, 2021

@XeonG This should be handed by semantic highlighting. Do you have csharp.semanticHighlighting.enable set to true in your vscode settings?

0reactions
heartackercommented, Aug 3, 2021

@XeonG This should be handed by semantic highlighting. Do you have csharp.semanticHighlighting.enable set to true in your vscode settings?

why don’t you make it true by default?curiousness

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scripting define symbols not working - Unity Forum
when I NEED to build the game i cant build it because of editor code. But when i put Editor code in #if...
Read more >
Conditional Compilation - Unity - Manual
First of all, select the platform you want to test your code against by going to File > Build Settings. This displays the...
Read more >
Visual Studio code highlight doesn't work with Unity project
If the project is loaded, there is still no code highlighting. This means that when you load the project file, the script file...
Read more >
Common Mistakes - OpenGL Wiki - Khronos Group
Thus, glGenTextures will not work correctly before context ... on the user to correctly use them, but it also makes their working code...
Read more >
50 Tips and Best Practices for Unity (2016 Edition)
This article describes many strategies for working with Unity to make ... later (for example, animation does not always scale correctly).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found