40 lines
2.6 KiB
Python
40 lines
2.6 KiB
Python
"""Derive LmGirl's persistent comparison controls from the existing JSON UI."""
|
|
import json
|
|
import copy
|
|
from pathlib import Path
|
|
|
|
root=Path(__file__).resolve().parents[1]
|
|
folder=root/'Doc/UIPrefabCreater'
|
|
document=json.loads((folder/'UI_CharacterAnimationLab.json').read_text(encoding='utf-8'))
|
|
old='UI_CharacterAnimationLab';new='UI_LmGirlAnimationLab'
|
|
document['prefabName']=new;document['prefabPath']=document['prefabPath'].replace(old,new)
|
|
document['description']='LmGirl Mixamo 网站、TokenRig 原始、体素后处理、局部约束四版同动作比较。'
|
|
extra=copy.deepcopy(next(n for n in document['nodes'] if n['name']=='Txt_Column2'));extra['name']='Txt_Column3';document['nodes'].append(extra)
|
|
for original in [n for n in document['nodes'] if n['name'] in ['Btn_Focus3','Txt_Focus3']]:
|
|
node=copy.deepcopy(original);node['name']=node['name'].replace('Focus3','Focus4')
|
|
if node.get('parent'):node['parent']=node['parent'].replace('Focus3','Focus4')
|
|
for c in node['components']:
|
|
if c.get('type')=='Button':c['onClick']='AnimationLab.Focus4'
|
|
if c.get('type')=='TextMeshProUGUI':c['text']='看 ④'
|
|
document['nodes'].append(node)
|
|
document['bindings'].append('Btn_Focus4');document['events'].append({'name':'AnimationLab.Focus4','node':'Btn_Focus4'})
|
|
labels={'Txt_Title':'LmGirl 同动作蒙皮对比','Txt_Subtitle':'网站 33 骨 / TokenRig 41 骨 · 同步动作',
|
|
'Txt_Column0':'① Mixamo 网站','Txt_Column1':'② 原始预测','Txt_Column2':'③ 体素后处理','Txt_Column3':'④ 局部约束',
|
|
'Txt_All':'四版并排'}
|
|
focus_row=['Btn_All','Btn_Focus1','Btn_Focus2','Btn_Focus3','Btn_Focus4','Btn_Detail']
|
|
for node in document['nodes']:
|
|
node['name']=node['name'].replace(old,new)
|
|
if node.get('parent'):node['parent']=node['parent'].replace(old,new)
|
|
for component in node.get('components',[]):
|
|
if component.get('type')=='TextMeshProUGUI' and node['name'] in labels:component['text']=labels[node['name']]
|
|
if node['name'].startswith('Txt_Column'):
|
|
i=int(node['name'][-1]);node['rect']['anchoredPosition'][0]=(i-1.5)*252;node['rect']['sizeDelta'][0]=250
|
|
node['components'][0]['fontSize']=24
|
|
node['components'][0]['color']=['#1B8299FF','#B46A2AFF','#7066A0FF','#458533FF'][i]
|
|
if node['name'] in focus_row:
|
|
width=(978-5*10)/6;i=focus_row.index(node['name']);node['rect']['sizeDelta'][0]=width
|
|
node['rect']['anchoredPosition'][0]=-489+width/2+i*(width+10)
|
|
if node['name']=='Txt_All':node['components'][0]['fontSize']=24
|
|
(folder/(new+'.json')).write_text(json.dumps(document,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
|
|
print(folder/(new+'.json'))
|