notepad-plus-plus / userDefinedLanguages

Notepad++ User Defined Languages Collection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there no UDL for scripting C# in Unity 3D

zenhund74 opened this issue · comments

Hello dear Notepad ++ developers

I found some hints that there might be a UDL for Unity 3D C#, but it is not in the list (anymore?) .
Any hints, on how to get hold of an UDL file for that?

I googled quite extensively, but didn't find anything.

With kind regards.

There is no Unity3D C# UDL shared with this repository, nor have I ever seen one linked on the community.notepad-plus-plus.org forum.

However, If "Unity 3D C#" is really just C# syntax, with some extra keywords, then UDL might not be the best choice: it's probably easiest to just assign the Unity 3D C# extension to be interpreted as C#, and then add extra keywords to the C# lexer:

  1. Settings > Style Configurator: click Language: C#
  2. User ext.: = u3d or whatever the extension of "Unity 3D C#" is
  3. The Style: INSTRUCTION WORD and TYPE WORD both have User-defined keywords boxes, where you can add in all the extra keywords for the "Unity 3D" keyword extensions to C#

If you'd rather have different colors for the "Unity 3D" keywords as compared to "standard" C# keywords, the built-in lexer isn't enough. But adding the plugin EnhanceAnyLexer, you can define a [c#] section in the config file (Plugins > Enhance Any Lexer > Open Configuration File). For example, if you wanted these fake keywords unity3d and deunify to show up as cyan, and magenta and purple keywords to show up as a magenta color:

[c#]
0xFFFF00 = \b(unity3d|deunify)\b
0xFF00FF = \b(magenta|purple)\b

image

If you have more words for the same color, just continue adding them inside those parentheses with | between. If you want other colors for other keywords, just use similar lines . The left side of the equal-sign is a color; the right side is a regular expression (the same syntax that's allowed in Notepad++'s regular expression search; the ;-prefixed comments in the default config file for that plugin explains more about the color syntax.

Hello pryrt,

thank you for your quick and competent answer. Well the Unity 3D extension for C# is .cs so basically the default extension. I could add some more default keywords for Instruction Word and Type Word. But if e.g. I would add the type Transform I would not get auto-completion to offer me some properties like Transform.position or Transform.rotation. Would that be possible by editing the language file? Maybe I could copy the original file and add important classes with their properties and functions step by step?

Kind regards.

the autoCompletion\cs.xml is a customizable configuration file; you can add any function completion you want to that file, and the next time you run Notepad++, those extra functions and parameters will be available for Function and Parameter Hint completion.

The user manual has a section on auto-completion. Please note the caveats on punctuation in auto-completion (your examples of Transform.rotation, for example).

Thank you very much, I think I'll go for customizing the cs.xml. Ideal would be writing a script that goes through the Unity Scripting API and generates the xml file. For me this topic can be closed.

Kind regards.