Skip to content

Add C# syntax highlighting #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Levels refer to what some people call maps or what Unity calls Scenes. A level c

<a name="terms-serializable"></a>
#### Serializable
Variables that are Serializable are shown in the Inspector window in Unity. For more information see Unity's documentation on [Serializable](https://docs.unity3d.com/Manual/script-Serialization.html).
Variables that are Serializable are shown in the Inspector window in Unity. For more information see Unity's documentation on [Serializable](https://docs.unity3d.com/ScriptReference/Serializable.html) and [script serialization](https://docs.unity3d.com/Manual/script-Serialization.html).

<a name="terms-cases"></a>
#### Cases
Expand Down Expand Up @@ -401,7 +401,7 @@ Within each of these groups order by access:
* internal
* protected
* private
```
```csharp
namespace ProjectName
{
/// <summary>
Expand Down Expand Up @@ -466,13 +466,13 @@ Use a namespace to ensure your scoping of classes/enum/interface/etc won't confl

Simply, any function that has an access modifier of Public should have its summary filled out.

```
```csharp
/// <summary>
/// Fire a gun
/// </summary>
public void Fire()
{
// Fire the gun.
// Fire the gun.
}
```

Expand All @@ -486,12 +486,12 @@ To create Foldout Groups there are 2 options in Unity.
* The first is to define a `[Serializable] public Class` inside the main class however this can have a performance impact. This allows the use of the same variable name to be shared.
* The second option is to use the Foldout Group Attribute available with [Odin Inspector](https://odininspector.com/).

```
[[Serializable](https://docs.unity3d.com/ScriptReference/Serializable.html)]
```csharp
[Serializable]
public struct PlayerStats
{
public int MovementSpeed;
}
{
public int MovementSpeed;
}

[FoldoutGroup("Interactable")]
public int MovementSpeed = 1;
Expand All @@ -513,16 +513,16 @@ End comment text with a period.
Insert one space between the comment delimiter (//) and the comment text, as shown in the following example.

The // (two slashes) style of comment tags should be used in most situations. Where ever possible, place comments above the code instead of beside it. Here are some examples:
```
// Sample comment above a variable.
private int _myInt = 5;
```csharp
// Sample comment above a variable.
private int _myInt = 5;
```

#### Regions
The `#region` directive enables you to collapse and hide sections of code in C# files. The ability to hide code selectively makes your files more manageable and easier to read.
```
```csharp
#region "This is the code to be collapsed"
Private components As System.ComponentModel.Container
private System.ComponentModel.IContainer components;
#endregion
```

Expand Down Expand Up @@ -590,7 +590,7 @@ Local variables should use camelCase.

###### Implicitly Typed Local Variables
Use implicit typing for local variables when the type of the variable is obvious from the right side of the assignment, or when the precise type is not important.
```
```csharp
var var1 = "This is clearly a string.";
var var2 = 27;
var var3 = Convert.ToInt32(Console.ReadLine());
Expand All @@ -600,7 +600,7 @@ for (var i = 0; i < bountyHunterFleets.Length; ++i) {};

Do not use var when the type is not apparent from the right side of the assignment.
Example
```
```csharp
int var4 = ExampleClass.ResultSoFar();
```

Expand All @@ -612,7 +612,7 @@ Unless it is known that a variable should only be accessed within the class it i

##### Do _Not_ use Hungarian notation
Do _not_ use Hungarian notation or any other type identification in identifiers
```
```csharp
// Correct
int counter;
string name;
Expand Down Expand Up @@ -659,7 +659,7 @@ Example: When defining a weapon, do **not** use `isReloading` and `isEquipping`
Enums use PascalCase and use singular names for enums and their values. Exception: bit field enums should be plural. Enums can be placed outside the class space to provide global access.

Example:
```
```csharp
public enum WeaponType
{
Knife,
Expand All @@ -685,7 +685,10 @@ Example: Use `Targets`, `Hats`, and `EnemyPlayers`, not `TargetList`, `HatArray`
##### Interfaces
Interfaces are led with a capital `I` then followed with PascalCase.

Example: ```public interface ICanEat { }```
Example:
```csharp
public interface ICanEat { }
```

<a name="functions"></a>
### 3.4 Functions, Events, and Event Dispatchers
Expand Down