#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class NameEditor : MonoBehaviour
{
[MenuItem("Tools/Rename Sprites in Texture")]
public static void RenameSprites()
{
string path = "Assets/Sprite/item/2_Cloth/Cloth_2.png";
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
if (importer != null && importer.spriteImportMode == SpriteImportMode.Multiple)
{
SpriteMetaData[] metas = importer.spritesheet;
foreach (var meta in metas)
{
Debug.Log("Before: " + meta.name);
}
for (int i = 0; i < metas.Length; i++)
{
if (metas[i].name == "Right_A") metas[i].name = "_Right";
if (metas[i].name == "Body_A") metas[i].name = "_Body";
if (metas[i].name == "Left_A") metas[i].name = "_Left";
}
importer.spritesheet = metas;
AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
AssetDatabase.Refresh();
}
}
}
#endif
경로는 확실해서 저렇게 반응이 있긴 한데
이름 자체는 안바뀜...
새로고침해봐도 똑같음
이름 바꾸는 if문에다가 중단점 걸어놓고 테스트 돌려봐 아예 바뀌지 않는 건지 바뀌는 건데 도로 원래대로 돌아가는 건지라도 알 수 있음
아 루프 중간에 리프레시도 넣어야겠구나