유니티 Dialogue System 시퀀서 명령어 만들기 및 활용법
유니티의 PixelCrushers Dialogue System을 사용할 때, CSV 내보내기 후 OnExecute 이벤트가 사라지는 문제를 해결하는 방법 중 하나로 시퀀서 명령어(Sequencer Command)를 활용할 수 있다.
시퀀서 명령어를 사용하면 다이얼로그에서 특정 기능을 직접 호출할 수 있으며, CSV 내보내기 후에도 유지된다.
이 글에서는 시퀀서 명령어를 만드는 방법과 다이얼로그에서 사용하는 방법을 설명한다.
1. 시퀀서 명령어란?
시퀀서 명령어는 Dialogue System에서 다이얼로그 진행 중 특정 기능을 실행할 수 있도록 하는 기능이다.
OnExecute 이벤트 대신 사용할 수 있으며, CSV 내보내기 후에도 사라지지 않는다.
2. 시퀀서 명령어 만들기
Dialogue System에서 시퀀서 명령어를 사용하려면 SequencerCommand 클래스를 상속받아야 한다.
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class SequencerCommandScreenFlash : SequencerCommand
{
public void Start()
{
Debug.Log("ScreenFlash 실행");
ScreenFlashEffect.Flash(Color.white, 0.2f);
Stop();
}
}
이제 다이얼로그에서 ScreenFlash() 명령어를 사용할 수 있다.
3. 다이얼로그에서 사용하기
이벤트가 발생하면 화면이 깜빡인다.
ScreenFlash()
이렇게 하면 다이얼로그 진행 중에 ScreenFlash() 명령어가 실행된다.
4. 스크립트 저장 위치
시퀀서 명령어는 프로젝트 내 어디에 있어도 실행되지만, 유지보수를 위해 Scripts/SequencerCommands/ 폴더를 만들어 정리하는 것이 좋다.
예시:
/Assets/Scripts/SequencerCommands/
├── SequencerCommandScreenFlash.cs
├── SequencerCommandPlaySound.cs
├── SequencerCommandShakeCamera.cs
5. 시퀀서 명령어 자동 등록 원리
Dialogue System에서는 SequencerCommand 클래스를 상속받은 스크립트를 자동으로 인식한다.
클래스명이 SequencerCommand로 시작하면, 뒤에 붙은 부분이 다이얼로그에서 사용할 명령어가 된다.
예시:
클래스명다이얼로그 명령어
SequencerCommandScreenFlash | ScreenFlash() |
SequencerCommandPlaySound | PlaySound() |
SequencerCommandShakeCamera | ShakeCamera() |
6. 결론
- OnExecute 이벤트 없이 다이얼로그에서 직접 함수 실행 가능
- CSV 내보내기 후에도 기능이 유지됨
- 다양한 이벤트(BGM 변경, 화면 깜빡임, 사운드 재생) 쉽게 실행 가능
- Dialogue Manager에 부착할 필요 없이 자동 실행
유니티 Dialogue System에서 OnExecute 이벤트가 CSV 내보내기 후 사라지는 문제를 해결하기 위해 Sequencer Command를 활용하면 다이얼로그에서 BGM 변경, 화면 깜빡임, 사운드 재생 등 다양한 이벤트를 직접 실행할 수 있으며, Dialogue Manager에 별도로 등록할 필요 없이 Scripts/SequencerCommands/ 폴더에 정리하면 자동으로 인식되어 유지보수가 쉬워지고, 클래스명을 SequencerCommand로 시작하면 뒤에 붙은 이름이 다이얼로그에서 사용할 명령어로 자동 등록되기 때문에 PlaySound(), ShakeCamera(), ScreenFlash() 같은 이벤트를 쉽게 실행할 수 있다.
To resolve the issue where the OnExecute event disappears after exporting a CSV in Unity's Dialogue System, utilizing Sequencer Commands allows direct execution of various events such as BGM changes, screen flashes, and sound playback within dialogues. There is no need to manually register them in the Dialogue Manager, as they are automatically recognized when organized in the Scripts/SequencerCommands/ folder, making maintenance easier. Additionally, if a class name starts with SequencerCommand, the following part is automatically registered as a dialogue command, enabling easy execution of events like PlaySound(), ShakeCamera(), and ScreenFlash().
'Unity' 카테고리의 다른 글
Unity AssetBundle Browser 설치 및 사용 방법 정리 (0) | 2025.04.09 |
---|---|
iOS ATT(App Tracking Transparency) 설정, 광고 추적 문제 해결 가이드 (0) | 2025.02.25 |
Unity에서 버튼 클릭 시 햅틱(진동) 피드백 적용하기 (iOS & Android) (0) | 2025.02.25 |
Unity에서 CocoaPods를 인식하지 못하는 문제 해결: macOS 기본 Ruby 문제 해결 방법 (0) | 2025.02.21 |
유니티에서 다국어 지원을 위한 TMP 폴백 폰트 설정법 (0) | 2025.02.17 |