Skip to content

Commit 1726579

Browse files
committed
Create snippets
1 parent 27952b4 commit 1726579

File tree

1 file changed

+245
-0
lines changed

1 file changed

+245
-0
lines changed

snippets.json

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
{
2+
"Dots Create ISystem": {
3+
"prefix": "dcs",
4+
"body": [
5+
"using Unity.Burst;",
6+
"using Unity.Entities;",
7+
"using Unity.Mathematics;",
8+
"using Unity.Transforms;",
9+
"",
10+
"namespace ${1}",
11+
"{",
12+
"\t[BurstCompile]",
13+
"\tpublic partial struct ${2:$TM_FILENAME_BASE} : ISystem",
14+
"\t{",
15+
"\t\tpublic void OnCreate(ref SystemState state)",
16+
"\t\t{",
17+
"\t\t\t${0}",
18+
"\t\t}",
19+
"",
20+
"\t\t[BurstCompile]",
21+
"\t\tpublic void OnUpdate(ref SystemState state)",
22+
"\t\t{",
23+
"\t\t\t",
24+
"\t\t}",
25+
"",
26+
"\t\tpublic void OnDestroy(ref SystemState state)",
27+
"\t\t{",
28+
"\t\t\t",
29+
"\t\t}",
30+
"\t}",
31+
"}"
32+
],
33+
"description": "Create a Unity DOTS System with the ISystem interface"
34+
},
35+
"Dots Create ISystem w/ onStart onStop": {
36+
"prefix": "dcsss",
37+
"body": [
38+
"using Unity.Burst;",
39+
"using Unity.Entities;",
40+
"using Unity.Mathematics;",
41+
"using Unity.Transforms;",
42+
"",
43+
"namespace ${1}",
44+
"{",
45+
"\t[BurstCompile]",
46+
"\tpublic partial struct ${2:$TM_FILENAME_BASE} : ISystem, ISystemStartStop",
47+
"\t{",
48+
"\t\tpublic void OnCreate(ref SystemState state)",
49+
"\t\t{",
50+
"\t\t\t${0}",
51+
"\t\t}",
52+
"",
53+
"\t\t[BurstCompile]",
54+
"\t\tpublic void OnUpdate(ref SystemState state)",
55+
"\t\t{",
56+
"\t\t\t",
57+
"\t\t}",
58+
"",
59+
"\t\tpublic void OnDestroy(ref SystemState state)",
60+
"\t\t{",
61+
"\t\t\t",
62+
"\t\t}",
63+
"\t}",
64+
"\t\tpublic void OnStartRunning(ref SystemState state)",
65+
"\t\t{",
66+
"\t\t\t",
67+
"\t\t}",
68+
"",
69+
"\t\tpublic void OnStopRunning(ref SystemState state)",
70+
"\t\t{",
71+
"\t\t\t",
72+
"\t\t}",
73+
"\t}",
74+
"}"
75+
],
76+
"description": "Create a Unity DOTS ISystem with onStartRunning & onStopRunning callbacks"
77+
},
78+
"Dots Create SystemBase": {
79+
"prefix": "dcsb",
80+
"body": [
81+
"using Unity.Entities;",
82+
"using Unity.Mathematics;",
83+
"using Unity.Transforms;",
84+
"",
85+
"namespace ${1}",
86+
"{",
87+
"\tpublic partial class ${2:$TM_FILENAME_BASE} : SystemBase",
88+
"\t{",
89+
"\t\tprotected override void OnCreate()",
90+
"\t\t{",
91+
"\t\t\t${0}",
92+
"\t\t}",
93+
"",
94+
"\t\tprotected override void OnUpdate()",
95+
"\t\t{",
96+
"\t\t\t",
97+
"\t\t}",
98+
"",
99+
"\t\tprotected override void OnDestroy()",
100+
"\t\t{",
101+
"\t\t\t",
102+
"\t\t}",
103+
"\t\tprotected override void OnStartRunning()",
104+
"\t\t{",
105+
"\t\t\t",
106+
"\t\t}",
107+
"",
108+
"\t\tprotected override void OnStopRunning()",
109+
"\t\t{",
110+
"\t\t\t",
111+
"\t\t}",
112+
"\t}",
113+
"}"
114+
],
115+
"description": "Create a managed Unity DOTS System with the SystemBase class"
116+
},
117+
"Dots Create Unmanaged Component": {
118+
"prefix": "dcc",
119+
"body": [
120+
"using Unity.Entities;",
121+
"",
122+
"namespace ${1}",
123+
"{",
124+
"\tpublic struct ${2:$TM_FILENAME_BASE} : IComponentData",
125+
"\t{",
126+
"\t\tpublic ${3:int} ${4:value};${0}",
127+
"\t}",
128+
"}"
129+
],
130+
"description": "Create a Unity DOTS unmanaged component (recommended if using blittable types)"
131+
},
132+
"Dots Create Managed Component": {
133+
"prefix": "dcmc",
134+
"body": [
135+
"using Unity.Entities;",
136+
"",
137+
"namespace ${1}",
138+
"{",
139+
"\tpublic class ${2:$TM_FILENAME_BASE} : IComponentData",
140+
"\t{",
141+
"\t\tpublic ${3:string} ${4:value};${0}",
142+
"\t}",
143+
"}"
144+
],
145+
"description": "Create a Unity DOTS managed component (only if using NON-blittable types)"
146+
},
147+
"Dots Create Managed Component w/ External Resource": {
148+
"prefix": "dcmcer",
149+
"body": [
150+
"using System;",
151+
"using UnityEngine;",
152+
"using Unity.Entities;",
153+
"",
154+
"namespace ${1}",
155+
"{",
156+
"\tpublic class ${2:$TM_FILENAME_BASE} : IComponentData, IDisposable, ICloneable",
157+
"\t{",
158+
"\t\tpublic ${3:ParticleSystem} ${4:ParticleSystem};${0}",
159+
"",
160+
"\t\tpublic void Dispose()",
161+
"\t\t{",
162+
"\t\t\t//garbage collection when this component is destroyed",
163+
"\t\t\tUnityEngine.Object.Destroy(${4:ParticleSystem});",
164+
"\t\t}",
165+
"",
166+
"\t\tpublic object Clone()",
167+
"\t\t{",
168+
"\t\t\t//duplicate a new particle system when this entity is duplicated",
169+
"\t\t\t//so that all copy entity instances do not use the same external resource",
170+
"\t\t\treturn new ${2:$TM_FILENAME_BASE} {",
171+
"\t\t\t\t${4:ParticleSystem} = UnityEngine.Object.Instantiate(${4:ParticleSystem})",
172+
"\t\t\t};",
173+
"\t\t}",
174+
"\t}",
175+
"}"
176+
],
177+
"description": "Create a Unity DOTS managed component referencing an external resource"
178+
},
179+
"Dots Create Unmanaged Shared Component": {
180+
"prefix": "dcsc",
181+
"body": [
182+
"using Unity.Entities;",
183+
"",
184+
"namespace ${1}",
185+
"{",
186+
"\tpublic struct ${2:$TM_FILENAME_BASE} : ISharedComponentData",
187+
"\t{",
188+
"\t\tpublic ${3:int} ${4:value};${0}",
189+
"\t}",
190+
"}"
191+
],
192+
"description": "Create a Unity DOTS unmanaged shared component (for components used on many entities & with the same values)"
193+
},
194+
"Dots Create Managed Shared Component": {
195+
"prefix": "dcmsc",
196+
"body": [
197+
"using System;",
198+
"using Unity.Entities;",
199+
"",
200+
"namespace ${1}",
201+
"{",
202+
"\tpublic struct ${2:$TM_FILENAME_BASE} : ISharedComponentData, IEquatable<${2:$TM_FILENAME_BASE}>",
203+
"\t{",
204+
"\t\tpublic ${3:string} ${4:value};${0}",
205+
"",
206+
"\t\tpublic bool Equals(${2:$TM_FILENAME_BASE} other)",
207+
"\t\t{",
208+
"\t\t\treturn ${4:value}.Equals(other.${4:value});",
209+
"\t\t}",
210+
"",
211+
"\t\tpublic override int GetHashCode()",
212+
"\t\t{",
213+
"\t\t\treturn ${4:value}.GetHashCode();",
214+
"\t\t}",
215+
"\t}",
216+
"}"
217+
],
218+
"description": "Create a Unity DOTS managed shared component (for shared components using non-blittable types)"
219+
},
220+
"Dots Create Tag Component": {
221+
"prefix": "dctc",
222+
"body": [
223+
"using Unity.Entities;",
224+
"",
225+
"namespace ${1}",
226+
"{",
227+
"\tpublic struct ${2:$TM_FILENAME_BASE} : IComponentData { }",
228+
"}"
229+
],
230+
"description": "Create a Unity DOTS tag component"
231+
},
232+
"Dots Create Job": {
233+
"prefix": "dcj",
234+
"body": [
235+
"public partial struct ${2:Calculation}Job : IJobEntity",
236+
"{",
237+
"\tvoid Execute(ref ${3:Component} ${4:component})",
238+
"\t{",
239+
"\t\t${0}",
240+
"\t}",
241+
"}"
242+
],
243+
"description": "Create a Unity DOTS Job"
244+
}
245+
}

0 commit comments

Comments
 (0)