【每天一个Unity技巧】批量修改Asset资源名称

2017-02-16  本文已影响503人  木心Sepith

今天给美术童鞋写了一个小工具来批量修改资源的名称,改一下newName的前缀,拿去用吧

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;

public class ReName
{

    [MenuItem("Tools/ReName")]
    public static void Rename()
    {
        Object[] m_objects = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);//选择的所以对象  

        int index = 0;//序号  

        foreach (Object item in m_objects)
        {
            if (Path.GetExtension(AssetDatabase.GetAssetPath(item)) != "")//判断路径是否为空  
            {

                string path = AssetDatabase.GetAssetPath(item);

                string newName = "Tex_" + index;
                AssetDatabase.RenameAsset(path, newName);
                index++;
            }

        }

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }

}

上一篇 下一篇

猜你喜欢

热点阅读