美文网首页
【每天一个Unity技巧】批量修改Asset资源名称

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

作者: 木心Sepith | 来源:发表于2017-02-16 15:23 被阅读503次

今天给美术童鞋写了一个小工具来批量修改资源的名称,改一下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();
    }

}

相关文章

网友评论

      本文标题:【每天一个Unity技巧】批量修改Asset资源名称

      本文链接:https://www.haomeiwen.com/subject/fkkhwttx.html