Skip to content

Commit b53a123

Browse files
committed
Create snippet for baker with external dependency
1 parent 27cbaa1 commit b53a123

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

snippets.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,37 @@
269269
"}"
270270
],
271271
"description": "Create a Unity DOTS component baker & its authoring monobehavior class"
272+
},
273+
"Dots Create Baker w/ Dependency": {
274+
"prefix": "dcbd",
275+
"body": [
276+
"using UnityEngine;",
277+
"using Unity.Entities;",
278+
"",
279+
"namespace ${1}",
280+
"{",
281+
"\tpublic class ${2:$TM_FILENAME_BASE} : MonoBehaviour",
282+
"\t{",
283+
"\t\tpublic ${3:GameObject} ${4:dataSource};",
284+
"\t}",
285+
"",
286+
"\tpublic class ${5:Component}Baker : Baker<${2:$TM_FILENAME_BASE}>",
287+
"\t{",
288+
"\t\tpublic override void Bake(${2:$TM_FILENAME_BASE} authoring)",
289+
"\t\t{",
290+
"\t\t\tDependsOn(authoring.${4:dataSource});",
291+
"\t\t\t",
292+
"\t\t\tif (authoring.${4:dataSource} == null) return;",
293+
"\t\t\t",
294+
"\t\t\tvar entity = GetEntity(TransformUsageFlags.Dynamic);",
295+
"\t\t\tAddComponent(entity, new ${5:Component}",
296+
"\t\t\t{",
297+
"\t\t\t\t${6:ComponentVariable} = authoring.${4:dataSource}.${0}",
298+
"\t\t\t});",
299+
"\t\t}",
300+
"\t}",
301+
"}"
302+
],
303+
"description": "Create a Unity DOTS component baker referencing another data source (i.e. mesh, gameObject, scriptable obj...)"
272304
}
273305
}

0 commit comments

Comments
 (0)