# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it here:
# https://github.com/bevry/cson#what-is-cson
# markdown文件扩展
'.source.gfm':
'一级标题':
'prefix': 'togreen'
'body': '<span style="color:green"> '
'一级标题':
'prefix': '1'
'body': '# '
# dot文件扩展
'.source.dot':
'->':
'prefix': 'left'
'body': '->'
'""':
'prefix': 'mao'
'body': '""'
'wancheng':
'prefix': 'togreen'
'body': '[color=lightblue2, style=filled]'
# lua文件扩展
'.source.lua':
'注释':
'prefix': 'mark'
'body': '--'
# cs文件快捷键
'.source.cs':
# 设计模式
'单例模式':
'prefix': 'singleton'
'body': """
public static $1 _单例;
void Awake () {
_单例 = this;
}
"""
# 场景
'切换场景':
'prefix': 'flyscene'
'body': """
SceneManager.LoadScene( "$1" , LoadSceneMode.Single );
using UnityEngine.SceneManagement;
"""
'输出':
'prefix': 'log'
'body': 'Debug.Log($1);'
# 保存数据
'保存持久数据':
'prefix': 'savedata'
'body': 'PlayerPrefs.SetFloat( "$1" , $2)'
'获取持久数据':
'prefix': 'loaddata'
'body': 'PlayerPrefs.GetFloat( "$1" )'
# 数据转换
'转化为float':
'prefix': 'strtofloat'
'body': 'float.Parse( $1 )'
# namespace
'ui命名空间':
'prefix': 'ui'
'body': 'using UnityEngine.UI;'
'scene命名空间':
'prefix': 'scene'
'body': 'using UnityEngine.SceneManagement;'
# ugui
'输入框内容':
'prefix': 'inputField'
'body': '$1.getComponent<InputField>().text'
# 延时
'延时':
'prefix': 'time'
'body': 'Invoke( "$1" , $2f );'
# 实例化预设
'实例化':
'prefix': 'clone'
'body': """
GameObject $1 = Instantiate( $2 , $3.transform.position,Quaternion.identity);
$4.transform.SetParent( $4.transform );"""
# 分辨率
'分辨率':
'prefix': 'resolution'
'body': 'Screen.SetResolution(1280, 960, true, 60);'
# 数据结构
'list构造':
'prefix': 'list'
'body': 'List<$2> $1 = new List<$3>();'
## list循环
'list遍历':
'prefix': 'listforeach'
'body':
"""
foreach(var item in lst)
{
item.xxx
}
"""
## Dictionary循环
'dict循环':
'prefix': 'dictforeach'
'body':
"""
Dictionary<string, int> dicts = new Dictionary<string, int>();
dicts.Add("d", 1);
dicts.Add("x", 2);
//3.0以上版本
foreach (var item in dicts)
{
Debug.Log(item.Key + item.Value);
}
//KeyValuePair<T,K>
foreach (KeyValuePair<string, int> kv in dicts)
{
Debug.Log(kv.Key + kv.Value);
}
//通过键的集合取
foreach (string key in dicts.Keys)
{
Debug.Log(key + dicts[key]);
}
//直接取值
foreach (int val in dicts.Values)
{
Debug.Log(val);
}
//非要采用for的方法也可
List<string> test = new List<string>(dicts.Keys);
for (int i = 0; i < dicts.Count; i++)
{
Console.WriteLine(test[i] + dicts[test[i]]);
}
"""
# 循环
'for循环':
'prefix': 'for'
'body': """
for( int index = 0; index < $1;index++ )
{
}"""
'for循环':
'prefix': 'foreach'
'body': """
foreach(int i in a)
{
Console .WriteLine (i);
}
"""
# 分层
'注释层':
'prefix': 'explain'
'body': """
/*************************************************************************************************
$1
*************************************************************************************************/
"""