エディタ拡張書いたの初めてなので記念に
ただの供養です
using UnityEditor;
using UnityEngine;
using System.Linq;
using System.IO;
/// <summary>
/// 指定したオブジェクトをコピーするやつ~
/// </summary>
public class CopyWizard : ScriptableWizard
{
public Object copyBaseAsset;
public string baseName = "";
[Multiline(20)]
public string createNameList;
private Object prevObject = null;
[MenuItem("Custom/Copy")]
static void Open()
{
DisplayWizard<CopyWizard>("一括コピー");
}
void OnWizardUpdate()
{
if (prevObject == copyBaseAsset) {
return;
}
prevObject = copyBaseAsset;
baseName = copyBaseAsset.name;
}
void OnWizardCreate()
{
var path = AssetDatabase.GetAssetPath(copyBaseAsset);
var extension = Path.GetExtension(path);
string dirPath = Path.GetDirectoryName(path);
var list = createNameList.SplitLine().ToList();
list.RemoveAll(str => {
return str.IsNullOrEmpty();
});
for (int i = 0; i < list.Count; i++) {
string fileName = baseName + list[i] + extension;
fileName = fileName.Trim();
string createPath = Path.Combine(dirPath, fileName);
AssetDatabase.CopyAsset(path, createPath);
AssetDatabase.ImportAsset(createPath);
}
}
}
BaseName + CreateNameListの改行で区切った分データができます
material_001 ~ 008まで できるよ