在做unity3d的一個增強工具,用到了下
有需要的朋友湊合看,go.name是string類型
go.name = Selection.activeGameObject.name;
Regex rex = new Regex(@"\d{1,}", RegexOptions.RightToLeft);
var result = rex.Match(go.name);
if (result.Success)
{
var tmp = int.Parse(result.Groups[0].Value);
tmp++;
go.name = rex.Replace(go.name, tmp.ToString());
}
else
{
go.name += "1";
}