Home > Mobile >  how to get color code on my code FOR EXAMPLE (Debug.Log) to be in a color?
how to get color code on my code FOR EXAMPLE (Debug.Log) to be in a color?

Time:12-04

s

I want someone to tell me how to put colors on the code so its easier for me to code.

CodePudding user response:

I think you forgot to select unity c# components when installing visual studio, try again with visual code

CodePudding user response:

If you are talking about Intellisense / syntax highlighting, you need to make sure that you installed Visual Studio Tools for Unity (Note this is needed for Visual Studio only and you may already have it installed). Then follow these steps:

  • Close Visual Studio
  • In Unity, go to Edit > Preferences > External Tools
  • Click on the External Script Editor dropdown (this should be on which ever Visual Studio editor you are using or any other supported editor).
  • Make sure Embedded packages and Local Packages is checked under Generate csproj files for:
  • Click on Regenerate project files
  • Open any C# script and check if syntax highlighting is working.

In the worst case, if that does not work, you can close Unity and delete everything except the Assets/ and Project Settings/ folders (as well as anything you explicitly added) in your project's root directory. Unity will regenerate the project folders and files again when you open the project in the editor. It may just be that some of your project files were corrupt.

Also, in case I misinterpreted your question and you are talking about coloring the output in the console window within the editor, you can try using rich text which I believe is supported by Unity's console window in the latest versions. Example:

Debug.Log("<color=red>this is red text</color>");

For more info on that: https://docs.unity3d.com/Packages/[email protected]/manual/StyledText.html

  • Related