Created
July 11, 2018 20:16
-
-
Save 5argon/5243d985b80501296b0dae69af696d60 to your computer and use it in GitHub Desktop.
Snippet for working with Unity ECS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Place your snippets for csharp here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", | |
// "$2" | |
// ], | |
// "description": "Log output to console" | |
// } | |
"Protected Override": { | |
"prefix": "po", | |
"body": [ | |
"protected override $0", | |
] | |
}, | |
"Native Array Kit": { | |
"prefix": "naark", | |
"body": [ | |
"NativeArray<int> $0naar;", | |
"protected override void OnCreateManager(int capacity)", | |
"{", | |
" naar = new NativeArray<int>(1, Allocator.Persistent);", | |
"}", | |
"", | |
"protected override void OnDestroyManager()", | |
"{", | |
" naar.Dispose();", | |
"}", | |
] | |
}, | |
"On Create - Destroy": { | |
"prefix": "oncredes", | |
"body": [ | |
"protected override void OnCreateManager(int capacity)", | |
"{", | |
"}", | |
"", | |
"protected override void OnDestroyManager()", | |
"{", | |
"}", | |
] | |
}, | |
"Native Array": { | |
"prefix": "naar", | |
"body": [ | |
"NativeArray<int> $0naar;", | |
"naar = new NativeArray<int>(1, Allocator.Persistent);", | |
"naar.Dispose();", | |
] | |
}, | |
"Job PCD": { | |
"prefix": "jobpcd", | |
"body": [ | |
"protected override JobHandle OnUpdate(JobHandle inputDeps)", | |
"{", | |
" var job = new Job()", | |
" {", | |
" };", | |
" return job.Schedule(this, inputDeps);", | |
"}", | |
"", | |
"struct Job : IJobProcessComponentData<$0>", | |
"{", | |
" public void Execute(ref )", | |
" {", | |
" }", | |
"}", | |
] | |
}, | |
"Job Parallel For": { | |
"prefix": "jobpara", | |
"body": [ | |
"protected override JobHandle OnUpdate(JobHandle inputDeps)", | |
"{", | |
" var job = new Job()", | |
" {", | |
" };", | |
" return job.Schedule(len, 1, inputDeps);", | |
"}", | |
"", | |
"struct Job : IJobParallelFor", | |
"{", | |
" public void Execute(int i)", | |
" {$0", | |
" }", | |
"}", | |
] | |
}, | |
"Job": { | |
"prefix": "job", | |
"body": [ | |
"protected override JobHandle OnUpdate(JobHandle inputDeps)", | |
"{", | |
" var job = new Job()", | |
" {", | |
" };", | |
" return job.Schedule(inputDeps);", | |
"}", | |
"", | |
"struct Job : IJob", | |
"{", | |
" public void Execute()", | |
" {$0", | |
" }", | |
"}", | |
] | |
}, | |
"Using Job": { | |
"prefix": "usejob", | |
"body": [ | |
"using Unity.Entities;", | |
"using Unity.Mathematics;", | |
"using Unity.Collections;", | |
"using Unity.Jobs;", | |
"using UnityEngine.Experimental.PlayerLoop;", | |
], | |
}, | |
"Debug Log": { | |
"prefix": "dbl", | |
"body": [ | |
"Debug.Log($\"$0\");" | |
], | |
}, | |
"Read Only Component Data Array": { | |
"prefix": "rocda", | |
"body": [ | |
"[ReadOnly] public ComponentDataArray<$0> datas;" | |
], | |
}, | |
"Read Only Shared Component Data Array": { | |
"prefix": "roscda", | |
"body": [ | |
"[ReadOnly] public SharedComponentDataArray<$0> datas;" | |
], | |
}, | |
"Subtractive Component": { | |
"prefix": "subt", | |
"body": [ | |
"[ReadOnly] public SubtractiveComponent<$0> no;" | |
], | |
}, | |
"Write Only Component Data Array": { | |
"prefix": "wocda", | |
"body": [ | |
"[WriteOnly] public ComponentDataArray<$0> datas;" | |
], | |
}, | |
"Component Data Array": { | |
"prefix": "cda", | |
"body": [ | |
"public ComponentDataArray<$0> datas;" | |
], | |
}, | |
"Read Only Component Array": { | |
"prefix": "roca", | |
"body": [ | |
"[ReadOnly] public ComponentArray<$0> components;" | |
], | |
}, | |
"Write Only Component Array": { | |
"prefix": "woca", | |
"body": [ | |
"[WriteOnly] public ComponentArray<$0> components;" | |
], | |
}, | |
"Component Array": { | |
"prefix": "ca", | |
"body": [ | |
"public ComponentArray<$0> components;" | |
], | |
}, | |
"Injection Group": { | |
"prefix": "injectgroup", | |
"body": [ | |
"struct InjectedGroup ", | |
"{$0", | |
"}", | |
"[Inject] InjectedGroup injectedGroup;", | |
], | |
}, | |
"Entity Array": { | |
"prefix": "ea", | |
"body": [ | |
"[ReadOnly] public EntityArray entities;", | |
], | |
}, | |
"Length": { | |
"prefix": "len", | |
"body": [ | |
"public readonly int Length;", | |
], | |
}, | |
"Group Index": { | |
"prefix": "groupindex", | |
"body": [ | |
"public readonly int GroupIndex;", | |
], | |
}, | |
"Readonly Public": { | |
"prefix": "rop", | |
"body": [ | |
"[ReadOnly] public $0", | |
], | |
}, | |
"Entity Command Buffer": { | |
"prefix": "enticom", | |
"body": [ | |
"public EntityCommandBuffer command;", | |
], | |
}, | |
"Barrier System": { | |
"prefix": "barr", | |
"body": [ | |
"public class Barrier$0 : BarrierSystem { }", | |
"[Inject] Barrier barrier;", | |
], | |
}, | |
"Get Barrier into a job": { | |
"prefix": "combar", | |
"body": [ | |
"command = barrier.CreateCommandBuffer(),", | |
], | |
}, | |
"Update Before": { | |
"prefix": "ubf", | |
"body": [ | |
"[UpdateBefore(typeof($0))]", | |
], | |
}, | |
"Update After": { | |
"prefix": "uaf", | |
"body": [ | |
"[UpdateAfter(typeof($0))]", | |
], | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment