def show(): #Data saveDir = r"\\vietsap002\projects\R6\04_WIP\tools\perforce\proxyCheck" rootDir = ue.get_content_dir() matchType = compile(r'\.uasset\Z') allstaticmeshes = ue.get_assets_by_class("StaticMesh") uassetfolders = ((root,files) for root, subdirs, files in os.walk(rootDir) if any(matchType.search(file) for file in files)) filterstaticmeshfolder = ((folder, list( staticmesh for staticmesh in allstaticmeshes if any(match("^{}".format(staticmesh.get_name()), ufile) for ufile in ufiles ))) for folder, ufiles in uassetfolders) staticmeshfolder = ((folder, files) for folder, files in filterstaticmeshfolder if files) #UI window = SWindow().resize(512,1024).set_title("Export Static Mesh") vertical = SVerticalBox() #style = ButtonStyle(Normal=SlateBrush(TintColor=SlateColor(SpecifiedColor=FLinearColor(1, 0, 0)))) #picker = SFilePathPicker(browse_title='Export To', browse_button_style=style, on_path_picked=path_picked) button = SButton().set_content(STextBlock().set_text("Export All").set_v_align(2) vertical.add_slot(button, v_align=0, h_align=0) vertical.add_slot(STextBlock().set_text("Export Folders:"), v_align=0, h_align=0) vertical.add_slot(picker, v_align=0, h_align=0) vertical.add_slot(STextBlock().set_text("Static Mesh Folders:"), v_align=0, h_align=0) for folder, ufiles in staticmeshfolder: button = SButton().set_content(STextBlock().set_text(os.path.relpath(folder, rootDir))).set_v_align(2) button.bind_on_clicked(partial(export, ufiles, saveDir)) #vertical.add_slot(button, v_align=2, h_align=2) vertical.add_slot(button, v_align=0, h_align=0) window.set_content(vertical) #window.set_modal(True) show()
def show(): rootDir = ue.get_content_dir() matchType = compile(r'\.uasset\Z') folders = (root for root, subdirs, files in os.walk(rootDir) if any(matchType.search(file) for file in files)) window = SWindow().resize(512,1024).set_title("Export Static Mesh") vertical = SVerticalBox() vertical.add_slot(STextBlock().set_text("Export Folders:"), v_align=2, h_align=0) for folder in folders: button = SButton().set_content(STextBlock().set_text(os.path.relpath(folder, rootDir))).set_v_align(2) #vertical.add_slot(button, v_align=2, h_align=2) vertical.add_slot(button, v_align=0, h_align=0) window.set_content(vertical) #window.set_modal(True)
thumbnails = [] for static_mesh in ue.get_assets_by_filter(_filter): thumbnails.append((static_mesh.get_full_name(), static_mesh.get_thumbnail())) window = SWindow(client_size=(1024, 512), title='StaticMeshes thumbnails') scroll_box = SScrollBox() vertical = SVerticalBox() for name, thumbnail in thumbnails: texture = ue.create_transient_texture(thumbnail.get_image_width(), thumbnail.get_image_height()) texture.texture_set_data(thumbnail.get_uncompressed_image_data()) vertical.add_slot( SHorizontalBox() ( SImage().set_texture(texture), max_width=64 ) ( STextBlock(text=name), padding=4, auto_width=True, ), max_height=64 ) scroll_box.add_slot(vertical) window.set_content(scroll_box)
horizontal = SHorizontalBox() button = SButton().set_content(STextBlock().set_text('Click ME !')) button.bind_on_mouse_button_down(clicked) button.bind_on_clicked(clicked2) box = SEditableTextBox() editor = SMultiLineEditableText() editor.set_text('Hello') grid = SGridPanel() grid.add_slot(button, 0, 0) grid.add_slot(box, 0, 1) grid.add_slot(editor, 0, 2) horizontal.add_slot(grid, v_align=2, h_align=2).add_slot(STextBlock().set_text('Second'), v_align=2, h_align=2) viewport = SPythonEditorViewport() world = viewport.get_world() bear_bp = ue.load_object(Blueprint, '/Game/Character3_Blueprint') bear = world.actor_spawn(bear_bp.GeneratedClass) horizontal.add_slot(viewport) window.set_content(horizontal)
import unreal_engine as ue from unreal_engine import SFilePathPicker, SWindow, FLinearColor from unreal_engine.structs import ButtonStyle, SlateBrush, SlateColor # a style is required for the file picker style = ButtonStyle(Normal=SlateBrush(TintColor=SlateColor( SpecifiedColor=FLinearColor(1, 0, 0)))) window = SWindow(client_size=(576, 576), title='Hello', modal=True) def path_picked(path): print(path) window.request_destroy() picker = SFilePathPicker(browse_title='Hello', browse_button_style=style, on_path_picked=path_picked) window.set_content(picker) window.add_modal()
class SetWindow: def __init__(self): self.window = SWindow(client_size=(680, 530), title='Resource List Check', sizing_rule=0) self.hori_0 = SHorizontalBox() self.hori_0_0 = SHorizontalBox() self.hori_1_0 = SHorizontalBox() self.hori_2 = SHorizontalBox() self.hori_2_0 = SHorizontalBox() #self.hori_3_0 = SHorizontalBox() self.vert_0 = SVerticalBox() #self.vert_2 = SVerticalBox() self.main_vertical = SVerticalBox() self.scroll = SScrollBox(orientation=EOrientation.Orient_Vertical) self.chk_grid = SGridPanel() top_vertical = (0, 0, 0, 0) mid_vertical = (0, -400, 0, -390) bot_vertical = (0, 390, 0, 0) #zero_padding = (0,0,0,0) self.newindex = [] self.newint = [] self.txt_01 = STextBlock(text='엑셀 테이블 경로 : ') self.etb = SEditableTextBox().assign('table_path') self.hori_0.add_slot(self.txt_01, fill_width=0.1) self.hori_0.add_slot(self.etb, fill_width=0.4) self.hori_0.add_slot(SButton(text='...', fill_width=0.1, on_clicked=lambda: self.fn_sp()), auto_width=True) self.hori_0.add_slot(SButton(text='@', fill_width=0.1, on_clicked=lambda: self.fn_test()), auto_width=True) self.hori_0_0.add_slot(SBorder()(self.hori_0), padding=top_vertical, v_align=EVerticalAlignment.VAlign_Top) self.hori_1_0.add_slot(SBorder()(self.vert_0), padding=mid_vertical, v_align=EVerticalAlignment.VAlign_Fill) self.hori_2.add_slot( SButton(text='선택리스트 저장-TXT', h_align=2, v_align=2, fill_width=0.1, on_clicked=lambda: fn_sel())) self.hori_2.add_slot( SButton(text='저장리스트 비교-TXT', h_align=2, v_align=2, fill_width=0.1, on_clicked=lambda: fn_readtext())) self.hori_2.add_slot(STextBlock(text=' 매칭 리스트 정렬 '), auto_width=True, v_align=EVerticalAlignment.VAlign_Center) self.hori_2.add_slot(sort_bool, auto_width=True) self.hori_2.add_slot(STextBlock(text=' 리스트에 없는 에셋만 표시 '), auto_width=True, v_align=EVerticalAlignment.VAlign_Center) self.hori_2.add_slot(checkbox_bool, auto_width=True) self.hori_2_0.add_slot(SBorder()(self.hori_2), padding=bot_vertical, v_align=EVerticalAlignment.VAlign_Fill) # 초기설정파일 셋팅 if fn_OpenDefaultSetting() != None: table_path.set_text(fn_OpenDefaultSetting()) #테이블 리스트 함수 - 설정 경로 바탕으로 리스트를 작성 합니다 if self.fn_resettable() != None: self.fn_resettable() else: ue.log('설정 파일이 없습니다') self.main_vertical.add_slot(self.hori_0_0) self.main_vertical.add_slot(SBorder()(self.scroll), padding=mid_vertical, v_align=EVerticalAlignment.VAlign_Fill) self.main_vertical.add_slot(self.hori_2_0) self.window.set_content(SBorder()(self.main_vertical)) # 테이블 버튼 리스트 생성 def fn_resettable(self): table_padding = (10, 5, 10, 5) btn_padding = (4, 4, 4, 4) # 기본 리스트 설정 self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=ctext.tableHeader_01)), column=0, row=0) self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=ctext.listHeader_01)), column=1, row=0) self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=ctext.listHeader_02)), column=2, row=0) self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=ctext.listHeader_03)), column=3, row=0) self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=ctext.listHeader_04)), column=4, row=0) # 테이블에서 엑셀 경로 가져오기 listxx = fn_Dafultxlsx(table_path.get_text()) if listxx == None: return None #ue.log(listxx) # 리스트 생성 for i in range(0, len(listxx)): bntlists.append(SetButtontlist(i)) i = 1 x = 0 for ttable in listxx: d = i name = ttable[0] #'엑셀파일 이름' sname = ttable[1] #'시트 이름' cname = ttable[2] #'컬럼 이름' uesasset = ttable[3] #'리소스 경로' self.chk_grid.add_slot(SBorder(padding=table_padding, h_align=2, v_align=2)( SEditableTextBox(text=str(i))), column=0, row=i) self.chk_grid.add_slot(SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=name)), column=1, row=i) self.chk_grid.add_slot(SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=sname)), column=2, row=i) self.chk_grid.add_slot(SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=cname)), column=3, row=i) # 버튼 리스트 ADD self.chk_grid.add_slot(SBorder(padding=btn_padding, v_align=2)(bntlists[i - 1].set_bnt), column=4, row=i) i += 1 self.scroll.add_slot(self.chk_grid, auto_width=True, auto_hight=True) def fn_test(self): ue.log('설정테스트') # 테이블 경로 - 가져오기 def fn_sp(self): try: st = fn_SaveDefaultSetting() table_path.set_text(st) if self.fn_resettable() != None: self.fn_resettable() except: ue.log('엑셀 기본 경로 설정을 취소 하였습니다') # 엑셀 테이블 읽기 위한 필요한 정보 (삭제 해야함 def fn_tt(self, path, tint): datacolumn = fn_Dafultxlsx(path) #ue.log(len(datacolumn)) #ue.log(tint) filepath = path + '/' + datacolumn[tint][0] + '.xlsx' sheetname = datacolumn[tint][1] findcolumn = datacolumn[tint][2] addstring = datacolumn[tint][3] fn_Loadxlsx(filepath, sheetname, findcolumn, addstring)
import unreal_engine as ue from unreal_engine import SFilePathPicker, SWindow, FLinearColor from unreal_engine.structs import ButtonStyle, SlateBrush, SlateColor # a style is required for the file picker style = ButtonStyle(Normal=SlateBrush(TintColor=SlateColor(SpecifiedColor=FLinearColor(1, 0, 0)))) window = SWindow(client_size=(576,576), title='Hello', modal=True) def path_picked(path): print(path) window.request_destroy() picker = SFilePathPicker(browse_title='Hello', browse_button_style=style, on_path_picked=path_picked) window.set_content(picker) window.add_modal()
class ClassTable: def __init__(self, text, textlist, tablename): tablenametext = tablename self.window = SWindow(client_size=(1024, 600), title='리소스 검색 결과 창' + tablename) self.vertical = SVerticalBox() self.horizon = SHorizontalBox() self.scroll = SScrollBox(orientation=EOrientation.Orient_Vertical) self.chk_grid = SGridPanel() table_padding = (10, 5, 10, 5) btn_padding = (4, 4, 4, 4) savepath = '' savelist = [] self.chk_grid.add_slot(SBorder(padding=btn_padding, v_align=2)(SButton( text='현재 리스트 TXT 파일로 저장', on_clicked=lambda: SaveText(textlist, tablenametext))), column=0, row=0, column_span=2) self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=text.tableHeader_01)), column=0, row=1) self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=text.tableHeader_02)), column=1, row=1) self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=text.tableHeader_05)), column=2, row=1) self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=text.tableHeader_04)), column=3, row=1) self.chk_grid.add_slot( SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=text.tableHeader_03)), column=4, row=1) #두번째 row 부터 리스트를 작성 한다. i = 2 for ttable in textlist: #range(1, 120): d = i color_val = color_gray stringsplit = ttable.split(',') name = stringsplit[0] path = stringsplit[1] assetname = stringsplit[2] uesasset = stringsplit[3] if '없음' == uesasset: color_val = color_red self.chk_grid.add_slot(SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=str(i - 1))), column=0, row=i) self.chk_grid.add_slot(SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock(text=name)), column=1, row=i) self.chk_grid.add_slot(SBorder(padding=table_padding, h_align=2, v_align=2)(STextBlock( text=uesasset, color_and_opacity=color_val)), column=2, row=i) self.chk_grid.add_slot(SBorder(padding=table_padding, h_align=2, v_align=2)( STextBlock(text=assetname)), column=3, row=i) self.chk_grid.add_slot(SBorder(padding=btn_padding, v_align=2)( SEditableTextBox(text=path)), column=4, row=i) i += 1 self.scroll.add_slot(self.chk_grid, auto_width=True, auto_hight=True) self.vertical.add_slot(SBorder()(self.scroll), auto_hight=True, padding=5) self.window.set_content(self.vertical)
button = SButton().set_content(STextBlock().set_text('Click ME !')) button.bind_on_mouse_button_down(clicked) button.bind_on_clicked(clicked2) box = SEditableTextBox() editor = SMultiLineEditableText() editor.set_text('Hello') grid = SGridPanel() grid.add_slot(button, 0, 0) grid.add_slot(box, 0, 1) grid.add_slot(editor, 0, 2) horizontal.add_slot(grid, v_align=2, h_align=2).add_slot(STextBlock().set_text('Second'), v_align=2, h_align=2) viewport = SPythonEditorViewport() world = viewport.get_world() bear_bp = ue.load_object(Blueprint, '/Game/Character3_Blueprint') bear = world.actor_spawn(bear_bp.GeneratedClass) horizontal.add_slot(viewport) window.set_content(horizontal)