Skip to content

Instantly share code, notes, and snippets.

@benui-dev
Created July 30, 2013 08:51
Show Gist options
  • Save benui-dev/6111355 to your computer and use it in GitHub Desktop.
Save benui-dev/6111355 to your computer and use it in GitHub Desktop.
Unity C# snippets for Vim Snipmate
snippet find
GameObject.Find("${1}")${2}
snippet gc
GetComponent<${1}>()
snippet ac
AddComponent<${1}>()
snippet sar
SetActiveRecursively(${1:true})
snippet rc
[RequireComponent (typeof(${1:AudioSource}))]
snippet ee
[ExecuteInEditMode]
snippet log
Debug.Log("${1:msg}");
snippet warn
Debug.LogWarning("${1:msg}");
snippet err
Debug.LogError("${1:msg}");
snippet inst
(${2:GameObject}) GameObject.Instantiate(${1:thing}, Vector3.zero, Quaternion.identity);
snippet go
GameObject ${1:go} = new GameObject(${2:name});
snippet s2i
Convert.ToInt32(${1:string})
snippet s2f
float.Parse(${1:string}, CultureInfo.InvariantCulture.NumberFormat)
snippet load
(${2:GameObject}) Resources.Load("${1:path}")
snippet wait
yield return new WaitForSeconds(${1:time})
snippet sm
SendMessage("${1:message}", ${2:null}, ${3:SendMessageOptions.DontRequireReceiver})
snippet forl
foreach (${1:int} ${2:var} in ${3:list}) {
${4}
}
snippet ford
foreach (KeyValuePair<${1:int}, ${2:int}> pair in ${3:dict}) {
${4}
}
snippet list
List<${1:int}> ${2:var} = new List<$1>();
snippet dict
Dictionary<${1:int}, ${2:int}> ${3:var} = new Dictionary<$1, $2>();
snippet sort
filtered.Sort(
delegate(${1:int} a, $1 b) {
return a.CompareTo(b);
}
);
snippet tryget
${1:int} ${2:value};
if (${3:dict}.TryGetValue("${4:key}", out $2)) {
${5}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment