在组件右键中添加静态方法(即在Inspector中邮件调用)
在静态方法上面添加[ContextMenu()]
[ContextMenu("替换")]
public void ReplaceName()
{
for (int i = 0; i < transform.childCount; i++)
{
string newName=transform.GetChild(i).name.Replace(origion, replace);
transform.GetChild(i).name = newName;
}
}
在工具栏添加方法按钮[MenuItem(“”)]
[MenuItem("\u26A1 Tools/存档管理/\u274C 删除所有存档")]
static void DeleteAllPresistence(MenuCommand command)
{
PlayerPrefs.DeleteAll();
System.IO.DirectoryInfo di = new DirectoryInfo(Application.persistentDataPath);
foreach (FileInfo file in di.GetFiles())
{
if (file.FullName.EndsWith(".sav"))
{
file.Delete();
}
}
}
在project面板右键添加按钮
[MenuItem(“Assets/”)]
把子项放在Assets下即可