> For the complete documentation index, see [llms.txt](https://docs.febucci.com/text-animator-unity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.febucci.com/text-animator-unity/3.x-ko/effects/setting-up-texts.md).

# 텍스트 설정하기

Text Animator에 텍스트를 두 가지 서로 다른 UI 시스템에서 설정할 수 있습니다:

* [#ui-toolkit](#ui-toolkit "mention")
* [#text-mesh-pro](#text-mesh-pro "mention")

{% hint style="info" %}
이 페이지에는 이미 다음에 있는 정보의 일부가 포함되어 있습니다 [설치 및 빠른 시작](/text-animator-unity/3.x-ko/quick-start/install-and-quick-start.md), 하지만 각 시스템과 전반적인 내용에 대한 다른 세부 사항과 제안도 있습니다. 반드시 다음을 읽어보세요 [#best-practices](#best-practices "mention") 섹션!&#x20;
{% endhint %}

***

## UI 툴킷

*추신. 이미 알고 있다고 가정합니다* [*UI 툴킷을 사용하는 방법을*](https://docs.unity3d.com/Documentation/Manual/UIElements.html) *그리고 그것이 무엇을 하는지.*

#### UI 빌더에서

{% columns %}
{% column width="58.333333333333336%" %}

* 라이브러리 -> 프로젝트로 이동하세요
* 다음을 드래그하세요 "<mark style="color:기본;background-color:yellow;">AnimatedLabel</mark>" 를 계층 구조에서 "Custom Controls/Febucci/Text Animator for Unity"에서!

{% hint style="info" %}
UI 툴킷에서 기본 제공 Label과 Button을 직접 애니메이션할 수 있도록 작업 중입니다! *(Unity 6.3 이상.)*  업데이트를 확인하세요!
{% endhint %}
{% endcolumn %}

{% column width="41.666666666666664%" %}
.uxml은 다음과 같이 보여야 합니다:

<figure><img src="/files/9384488d5a574456471f9085056c965539e265b3" alt="" width="302"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

#### 코드로

다음 "의 인스턴스를 생성할 수 있습니다<mark style="color:기본;background-color:yellow;">Febucci.TextAnimatorForUnity.AnimatedLabel</mark>" 클래스와 UI 문서에 추가하세요, 다음과 같이:

```csharp
using UnityEngine;
using UnityEngine.UIElements;
using Febucci.TextAnimatorForUnity; // <- Text Animator의 네임스페이스를 임포트합니다

public class ExampleScript : MonoBehaviour
{ 
    [SerializeField] UIDocument document;

    void Start()
    {
        var container = document.rootVisualElement.contentContainer;
        var animatedLabel = new AnimatedLabel(); // <- 애니메이션 라벨을 생성합니다
        container.Add(animatedLabel); // <- 콘텐츠 컨테이너에 추가합니다
        // [..]
        animatedLabel.SetText("<wave>hello"); // <- 텍스트를 설정합니다
    }
}
```

{% hint style="success" %}
이제 끝입니다!! 다음을 사용할 준비가 되었습니다 [효과를 추가하는 방법](/text-animator-unity/3.x-ko/effects/how-to-add-effects.md)
{% endhint %}

***

## Text Mesh Pro

*추신. 이미 알고 있다고 가정합니다* [*Text Mesh Pro를 사용하는 방법*](https://docs.unity3d.com/Packages/com.unity.ugui@2.0/manual/TextMeshPro/index.html) *그리고 그것이 어떻게 작동하는지.*

추가하기 <mark style="color:기본;background-color:yellow;">텍스트 애니메이터 - Text Mesh Pro</mark> 같은 GameObject에 구성 요소로 <mark style="color:기본;background-color:yellow;">TextMeshPro</mark> 구성요소(UI 또는 월드 공간 모두 가능!):

인스펙터는 다음과 같이 보여야 합니다:

<figure><img src="/files/dea141e7e469041bcb76076d1e568d1bacc0d7bc" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
이제 끝입니다!! 다음을 사용할 준비가 되었습니다 [효과를 추가하는 방법](/text-animator-unity/3.x-ko/effects/how-to-add-effects.md)
{% endhint %}

{% hint style="warning" %}
비어 있는 텍스트가 보인다면(하지만 컴포넌트에는 설정해 두었다면), TextMeshPro 컴포넌트를 최소 한 번은 클릭하고 "Essentials"를 가져왔는지 확인하세요(창이 나타나면 그렇게 하라고 요청할 것입니다).
{% endhint %}

#### 코드로 텍스트를 설정할 때의 모범 사례

코드로 TextMeshPro 오브젝트에 텍스트를 설정하려면, 다음과 같이 TMPro 대신 Text Animator의 스크립트를 참조하세요:

```csharp
using UnityEngine;
using TMPro; 
using Febucci.TextAnimatorForUnity.TextMeshPro; // <- Text Animator의 네임스페이스를 가져옵니다

public class ExampleScript : MonoBehaviour
{
    [SerializeField] TMP_Text textMeshPro;
    [SerializeField] TextAnimator_TMP textAnimator;

    void Start()
    {
        // 🚫 하지 마세요: TMPro를 통해 텍스트를 설정
        textMeshPro.SetText("<wave>hello");

        // ✅ 하세요: Text Animator를 통해 직접 텍스트를 설정
        textAnimator.SetText("<wave>hello");
    }

}
```

{% hint style="info" %}
참고: TMPro를 참조해도 어쨌든 동작하지만, TextAnimator로 텍스트를 설정하는 편이 텍스트를 더 잘 제어할 수 있어 통합이 더 좋습니다.
{% endhint %}

***

## 모범 사례

### 전체 텍스트/대사를 한 번만 설정하세요

텍스트는 한 번만 설정하고, 타자기/표시 방법으로 어떻게 나타날지 제어해 보세요.

{% hint style="info" %}
정말 나중에 텍스트를 덧붙여야 한다면 "textAnimator.AppendText" 메서드를 사용할 수 있습니다.
{% endhint %}

<details>

<summary>예시</summary>

캐릭터가 "Helloooo how are you doing?"라고 말하고 있고, 이를 글자 하나씩 표시하고 싶다면, 다음과 같이 하면 됩니다: `typewriter.ShowText("Hellooooo how are you doing?");` 이게 전부입니다! [글자를 동적으로 표시하고 숨기기](/text-animator-unity/3.x-ko/typewriter/show-and-hide-letters-dynamically.md)

***

동적 문자열을 만들고 있다면, 타자기/애니메이터에 값을 설정하기 전에 여전히 그렇게 할 수 있습니다.

```csharp
int apples = 5; //later taken from the game state
string playerName = "Bob";

// 먼저 전체 대사 줄을 만듭니다
string dialogue = $"Hello {playerName}, you've got {apples} apples";

// 그런 다음 텍스트를 한 번만 설정합니다
typewriter.ShowText(dialogue);
```

(Dialogue System을 사용 중이라면, 그 시스템이 이 작업을 대신해 줄 것입니다 - 걱정 마세요 ! [통합](/text-animator-unity/3.x-ko/integrations/integrated-plugins-and-dialogues-systems.md))

</details>

<details>

<summary>왜 문자를 하나씩이 아니라 전체 텍스트를 한 번만 설정해야 하나요?</summary>

성능 때문입니다! (Text Animator가 없더라도 마찬가지입니다.)

텍스트를 설정할 때마다 TextMeshPro 또는 UI 툴킷은 메시, 위치 지정 등을 계산해야 하고, 이후 Text Animator도 문자 지속 시간 등 여러 가지를 다시 계산해야 합니다. 즉, 이를 초당 여러 번 변경한다면(예: 글자를 더 추가한다면), 매번 이러한 계산을 수행하게 됩니다.

문자를 하나씩 표시하려면, 전체 텍스트를 한 번만 설정한 다음 타자기를 시작하면 됩니다: [글자를 동적으로 표시하고 숨기기](/text-animator-unity/3.x-ko/typewriter/show-and-hide-letters-dynamically.md)&#x20;

</details>
