Chapter1
处理touch
void Update()
{
if(!Application.isMobilePlatform)
{
if(Input.GetMouseButtonUp(0))
{
GetComponent<CubeGenerator>().Generate();
}
}
else
{
if(Input.touchCount >= 1)
{
Touch touch = Input.GetTouch(0);
if(touch.phase == TouchPhase.Began)
{
GetComponent<CubeGenerator>().Generate();
}
}
}
}
快捷键
F2 rename
alt shift A hide/show gameobject
Chapter3
读取sprite
selectedSprites.AddRange(AssetDatabase.LoadAllAssetsAtPath(
AssetDatabase.GetAssetPath(texture)).OfType());
正则表达测试
http://regexr.com/
排序的例子
string suffixPattern = "_?([0-9]+)$";
selectedSprites.Sort((Sprite _1, Sprite _2)=>{
Match match1 = Regex.Match(_1.name, suffixPattern);
Match match2 = Regex.Match(_2.name, suffixPattern);
if(match1.Success && match2.Success)
{
return (int.Parse(match1.Groups[1].Value) -
int.Parse(match2.Groups[1].Value));
}
else
{
return _1.name.CompareTo(_2.name);
}
});
using
The reason for the “using” statement is to ensure that the object is disposed as soon as it goes out of scope, and it doesn’t require explicit code to ensure that this happens.
Mono ctrl + V bug
Funny thing is you can also paste in the search (ctrl-f), then select all (ctrl-a) .. Copie and then your paste will work…