代码拉取完成,页面将自动刷新
try destroydialog BatchRename catch()
rollout BatchRename "批量改名"
(
local exArr = #()
local ini = getFilenamePath (getThisScriptFilename()) + "BatchRename.ini"
dropdownList pre "前缀 " items:#("Fifth_","Six_") editable:true
checkbox cb1 "贴图改名" checked:true
checkbox cb2 "材质改名" checked:true
checkbox cb3 "物体改名" checked:true
button btn "开 始 命 名" width:100 height:25
listbox lst width:120 height:6 align:#center
edittext txt across:2 width:75 offset:[-15,-5]
button btn1 "添加" offset:[15,-7] tooltip:"添加要清除的字符"
hyperLink hyp1 "By:Fifth" address:"https://gitee.com/FifthGently" color:orange hoverColor:red visitedColor:gray align:#right
on BatchRename open do
(
local str = getIniSetting ini "Default" "names"
exArr = filterString str "|"
lst.items = exArr
)
on btn1 pressed do
(
local str =(dotnetObject "System.String" txt.text).Trim()
if str != "" then
(
append exArr str
setIniSetting ini "Default" "names" ((dotnetClass "System.String").Join "|" exArr)
lst.items = exArr
lst.selection = lst.items.count
txt.text = ""
)
)
on btn pressed do
(
if not cb1.checked and not cb2.checked and not cb3.checked then
return messagebox "官人,您至少选一个吧!"
local msgs = #()
--if maxfilePath == "" then
--return messagebox "请先保存场景!"
local pth = maxfilePath + getfilenameFile maxfilename + "\\"
makeDir pth
if cb1.checked then
(
local objs = objects as array
for obj in selection do
(
strMapPath = obj.Material.diffuseMap.filename
print strMapPath
strPath = getFilenamePath strMapPath
strType = getFilenameType strMapPath
zhongwen = "你好"
DotNetAssembly = dotNetClass "System.Reflection.Assembly"
DotNetActivator = DotNetClass "System.Activator"
floderPath = getFilenamePath (getThisScriptFilename())
print floderPath
Assembly = DotNetAssembly.LoadFile (floderPath + "C# DLL\NPinyin.Core.dll")
NPinyinClassType = Assembly.GetType("NPinyin.Pinyin")
pingyin = (dotnetClass "NPinyin.Pinyin").GetPinyin(zhongwen)
--ClassObject = DotNetActivator.CreateInstance NPinyinClassType
--pingyin = NPinyinClassType.GetPinyin(zhongwen)
strNewPath = (strPath + pingyin + strType)
print strNewPath
renameFile strMapPath strNewPath
obj.Material.diffuseMap.filename =strNewPath
)
)
if cb2.checked then
(
local mats = makeuniquearray
(
for m in scenematerials where superclassof m == material collect m
)
for m in mats do
(
local end = m.name
for it in pre.items + lst.items do
end = substituteString end it ""
m.name = pre.selected + end
)
append msgs ("完成材质命名 " + mats.count as string + " 个!")
)
if cb3.checked then
(
local objs = objects as array
for o in objs do
(
local end = o.name
for it in pre.items + lst.items do
end = substituteString end it ""
o.name = pre.selected + end
)
append msgs ("完成物体命名 " + objs.count as string + " 个!")
)
if msgs.count > 0 then messagebox ((dotnetClass "System.String").Join "\n" msgs)
)
)
createDialog BatchRename 120 270
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。