본문 바로가기
이펙트 (FX)/이펙트 팁 : Unreal

[Unreal/Python] 시퀀서에서 여러 액터의 스폰 끄고 켜기

by Minkyu Lee 2024. 2. 29.

 

개요

시퀀서에서 렌더링시 합성을 위해 여러가지 이펙트 요소 중, 일부만 렌더하고 싶을 때가 있다.
그럴 때마다 개별적으로 스폰을 꺼주는 것이 굉장히 번거로웠다.
이를 개선하기 위해 만들게 되었다.
 

설명

시퀀서의 하이라키 구조는 다음과 같다.
바인딩 >> 트랙 >> 섹션

레벨 시퀀스에서 선택된 바인딩들을 가져온다.
바인딩의 트랙에 접근해 스폰 트랙인지 판별한다.
스폰 트랙의 섹션에 접근해 스폰 여부를 작동한다.

코드

import unreal as ue

def spawn_track_toggle(binding):
    tracks = binding.get_tracks()
    for track in tracks :
        track_name = track.get_display_name()
        if track_name == "스폰됨" : # 스폰 트랙이라면
            section = track.get_sections()[0]
            if section.is_active() :
                section.set_is_active(0)
            else :
                section.set_is_active(1)

bindings = ue.LevelSequenceEditorBlueprintLibrary.get_selected_bindings()
for binding in bindings :
    spawn_track_toggle(binding)

 

개선점

track의 display name이 아닌, type으로 판별할 수 있게 하면 더 깔끔할 것이다.
 

참고문서

언리얼 Python API 관련문서
https://docs.unrealengine.com/5.1/en-US/PythonAPI/class/LevelSequenceEditorBlueprintLibrary.html

댓글