You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A library for generating source code from templates in Unity
@@ -17,7 +18,9 @@ A library for generating source code from templates in Unity
17
18
18
19
## Usage
19
20
20
-
Create a `public static void` method in a class anywhere in your Unity project and decorate it with the `[CodeGenerationMethod]` attribute. This will make the method visible to the code generator. If you want to expose the method to the "Code Generation" menu add a `[MenuItem(...)]` attribute.
21
+
Create a `public static void` method in a class anywhere in your Unity project and decorate it with the `[CodeGenerationMethod]` attribute. This will make the method visible to the code generator.
22
+
23
+
If you want to expose the method to the "Code Generation" menu add a `[MenuItem(...)]` attribute.
21
24
22
25
```csharp
23
26
publicstaticclassMyClass
@@ -42,8 +45,7 @@ public static class MyClass
42
45
}
43
46
```
44
47
45
-
Additionally you need a template file in your project which the code generator can use.
46
-
Value names are case sensitive e.g. if you want to insert the value of the `data.Text` property in the data object you can do this by surrounding it with `{{ }}`. Accessing nested properties is the same as in C# e.g. `Animal.Color`.
48
+
Additionally you need a template file e.g. `MyTemplate.txt` in your project which the code generator can use.
47
49
48
50
```
49
51
// This is a sample template
@@ -62,7 +64,9 @@ public class My{{ color }}Class
62
64
{{ end }}
63
65
```
64
66
65
-
The generated file `MyTemplate.generated.cs` will look like this:
67
+
Value names are case sensitive e.g. if you want to insert the value of the `data.Text` property from the data object you can do this by surrounding it with `{{ }}`. Accessing nested properties is the same as in C# e.g. `Animal.Color`.
68
+
69
+
The generated file `MyTemplate.generated.cs` from this example will look like this:
0 commit comments