# 입력 중 이벤트 트리거하기

이벤트는 특정 텍스트 부분에 도달했을 때 타입라이터가 어떤 리스너 스크립트에 문자열 메시지를 보낼 수 있게 해주는 특수 태그입니다. *(이런 이유로 이벤트는 타입라이터가 활성화된 경우에만 작동합니다)*

<figure><img src="https://content.gitbook.com/content/XuXUTa2X5PYuYL6yRvl1/blobs/3UxVpaMvfQpqNMeoWA2v/textanimatorgif2febucci.gif" alt="textanimatorgif2febucci"><figcaption><p>장면 '예제 3 - 이벤트'</p></figcaption></figure>

***

## 개요 <a href="#overview" id="overview"></a>

리치 텍스트 태그를 사용하여 텍스트에 이벤트를 작성할 수 있습니다.

### 형식 <a href="#formatting" id="formatting"></a>

이벤트의 메시지는 물음표로 시작합니다. 예: `<?eventMessage>`.

**예:** ‘shakeCamera’라는 이벤트를 호출하려면 다음과 같이 작성하세요: `<?shakeCamera>`

* 👍🏻 이벤트는 내장 이펙트 태그를 포함한 어떤 종류의 태그도 가질 수 있습니다.
* ⚠️ 이벤트는 대소문자를 구분합니다. 이렇게 작성하는 것은 `<?camshake>` 와 같지 않습니다 `<?camShake>`. 주의하세요! (또는 스크립트에서 `string.ToLower()` 메서드를 사용해 이를 보정하세요.)

### 매개변수 <a href="#parameters" id="parameters"></a>

이벤트는 하나 이상의 매개변수를 가질 수 있습니다(첫 번째는 `=` 기호로 시작하고 다른 매개변수는 쉼표로 구분 `,`), 스크립트로 여러 데이터를 보낼 수 있습니다.

* 하나의 매개변수: `<?eventID=parameter1>`, 는 “eventID”라는 메시지와 “parameter1”이라는 하나의 매개변수를 생성합니다.
* 여러 매개변수: `<?eventID=p1,p2>`, 는 “eventID”라는 메시지와 “p1” 및 “p2”라는 매개변수를 생성합니다.

***

## 이벤트 수신 <a href="#listening-to-events" id="listening-to-events"></a>

이벤트/메시지를 수신하려는 스크립트는 `onMessage` 콜백에 구독해야 합니다 `Typewriter` 클래스 내부에. ([스크립팅 API](https://www.api.febucci.com/tools/text-animator-unity/api/Febucci.UI.Core.TypewriterCore.html#Febucci_UI_Core_TypewriterCore_onMessage)).

예:

```csharp
// 스크립트 내부
[SerializeField] TypewriterComponent typewriter;

// 콜백을 추가하고 제거합니다
void OnEnable() => typewriter.onMessage.AddListener(OnMessage);
void OnDisable() => typewriter.onMessage.RemoveListener(OnMessage);

// 수신된 마커에 따라 처리합니다
void OnMessage(EventMarker marker)
{
    switch (marker.name)
    {
        // 타입라이터가 "<?something>" 태그를 만났을 때
        
        case "something":
            // 무언가를 수행합니다
            break;
    }
}
```

👍🏻 “message” 문자열에는 ‘<’, ‘?’ 및 ‘>’ 문자가 없고 메시지 텍스트만 포함되어 있다는 점에 유의하세요.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.febucci.com/text-animator-unity/3.x-ko/typewriter/trigger-events-when-typing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
