Skip to content

Commit 699f0ee

Browse files
Added option to add file header comment
1 parent b2fc4aa commit 699f0ee

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

Editor/GenerateFileEditorWindow.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class GenerateFileEditorWindow : EditorWindow {
1717
private string fileName;
1818
private bool shouldOverwriteAllVirtuals;
1919
private bool shouldImportCommonNamespaces;
20+
private bool shouldAddFileHeaderComments;
2021

2122
[MenuItem ("ECS/Generate Controller", false, 100)]
2223
private static void GenerateNewController () {
@@ -53,6 +54,7 @@ private void OnGUI () {
5354
GUILayout.FlexibleSpace ();
5455
this.shouldImportCommonNamespaces = GUILayout.Toggle (this.shouldImportCommonNamespaces, " Import Common Namespaces");
5556
this.shouldOverwriteAllVirtuals = GUILayout.Toggle (this.shouldOverwriteAllVirtuals, " Overwrite All Virtuals");
57+
this.shouldAddFileHeaderComments = GUILayout.Toggle (this.shouldAddFileHeaderComments, " Add File Header Comments");
5658
GUILayout.FlexibleSpace ();
5759
if (GenerateFileEditorWindow.generateFileType == GenerateFileType.Controller) {
5860
if (GUILayout.Button ("Generate " + this.fileName + "Controller"))
@@ -72,6 +74,7 @@ private void OnGUI () {
7274
private void Generate () {
7375
var _overwriteAllVirtuals = this.shouldOverwriteAllVirtuals;
7476
var _importCommonNamespaces = this.shouldImportCommonNamespaces;
77+
var _addFileHeaderComments = this.shouldAddFileHeaderComments;
7578
var _fileName = this.fileName;
7679
this.fileName = "";
7780

@@ -80,7 +83,14 @@ private void Generate () {
8083
_importCommonNamespaces ? "using UnityEngine;" : null,
8184
"using ElRaccoone.EntityComponentSystem;",
8285
_importCommonNamespaces ? "using System.Collections.Generic;" : null,
83-
"public class " + _fileName + "Controller : Controller {",
86+
"",
87+
_addFileHeaderComments ? "/*" : null,
88+
_addFileHeaderComments ? " * Project: " + PlayerSettings.productName : null,
89+
_addFileHeaderComments ? " * Author: " : null,
90+
_addFileHeaderComments ? " *" : null,
91+
_addFileHeaderComments ? " * Controller for " + _fileName + "." : null,
92+
_addFileHeaderComments ? " */" : null,
93+
"public class " + _fileName + "Controller : Controller {",
8494
"\tpublic override void OnInitialize () {",
8595
"\t\tthis.Register();",
8696
"\t}",
@@ -94,6 +104,13 @@ private void Generate () {
94104
_importCommonNamespaces? "using UnityEngine;" : null,
95105
"using ElRaccoone.EntityComponentSystem;",
96106
_importCommonNamespaces? "using System.Collections.Generic;" : null,
107+
"",
108+
_addFileHeaderComments ? "/*" : null,
109+
_addFileHeaderComments ? " * Project: " + PlayerSettings.productName : null,
110+
_addFileHeaderComments ? " * Author: " : null,
111+
_addFileHeaderComments ? " *" : null,
112+
_addFileHeaderComments ? " * Entity Component for " + _fileName + "." : null,
113+
_addFileHeaderComments ? " */" : null,
97114
"public class " + _fileName + "Component : EntityComponent<" + _fileName + "Component, " + _fileName + "System> {",
98115
"}"
99116
});
@@ -103,6 +120,13 @@ private void Generate () {
103120
_importCommonNamespaces? "using UnityEngine;" : null,
104121
"using ElRaccoone.EntityComponentSystem;",
105122
_importCommonNamespaces? "using System.Collections.Generic;" : null,
123+
"",
124+
_addFileHeaderComments ? "/*" : null,
125+
_addFileHeaderComments ? " * Project: " + PlayerSettings.productName : null,
126+
_addFileHeaderComments ? " * Author: " : null,
127+
_addFileHeaderComments ? " *" : null,
128+
_addFileHeaderComments ? " * Entity System for " + _fileName + "." : null,
129+
_addFileHeaderComments ? " */" : null,
106130
"public class " + _fileName + "System : EntitySystem<" + _fileName + "System, " + _fileName + "Component> {",
107131
_overwriteAllVirtuals ? "\tpublic override void OnInitialize () { }" : null,
108132
_overwriteAllVirtuals ? "\tpublic override void OnInitialized () { }" : null,
@@ -125,6 +149,13 @@ private void Generate () {
125149
_importCommonNamespaces? "using UnityEngine;" : null,
126150
"using ElRaccoone.EntityComponentSystem;",
127151
_importCommonNamespaces? "using System.Collections.Generic;" : null,
152+
"",
153+
_addFileHeaderComments ? "/*" : null,
154+
_addFileHeaderComments ? " * Project: " + PlayerSettings.productName : null,
155+
_addFileHeaderComments ? " * Author: " : null,
156+
_addFileHeaderComments ? " *" : null,
157+
_addFileHeaderComments ? " * Service for " + _fileName + "." : null,
158+
_addFileHeaderComments ? " */" : null,
128159
"public class " + _fileName + "Service : Service<" + _fileName + "Service> {",
129160
_overwriteAllVirtuals ? "\tpublic override void OnInitialize () { }" : null,
130161
_overwriteAllVirtuals ? "\tpublic override void OnInitialized () { }" : null,

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Entity Component System
66

7-
[![npm](https://img.shields.io/badge/upm-3.4.0-232c37.svg?style=for-the-badge)]()
7+
[![npm](https://img.shields.io/badge/upm-3.4.1-232c37.svg?style=for-the-badge)]()
88
[![license](https://img.shields.io/badge/license-Custom-%23ecc531.svg?style=for-the-badge)](./LICENSE.md)
99
[![npm](https://img.shields.io/badge/sponsor-donate-E12C9A.svg?style=for-the-badge)](https://paypal.me/jeffreylanters)
1010
[![npm](https://img.shields.io/github/stars/elraccoone/unity-entity-component-system.svg?style=for-the-badge)]()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nl.elraccoone.entity-component-system",
33
"displayName": "Entity Component System",
4-
"version": "3.4.0",
4+
"version": "3.4.1",
55
"unity": "2019.1",
66
"description": "A better approach to game design that allows you to concentrate on the actual problems you are solving: the data and behavior that make up your game. By moving from object-oriented to data-oriented design it will be easier for you to reuse the code and easier for others to understand and work on it."
77
}

0 commit comments

Comments
 (0)