chore: Assets 디렉토리 구조 정리 및 네이밍 컨벤션 적용
- Assets/_Game/ 하위로 게임 에셋 통합 - External/ 패키지 벤더별 분류 (Synty, Animations, UI) - 에셋 네이밍 컨벤션 확립 및 적용 (Data_Skill_, Data_SkillEffect_, Prefab_, Anim_, Model_, BT_ 등) - pre-commit hook으로 네이밍 컨벤션 자동 검사 추가 - RESTRUCTURE_CHECKLIST.md 작성 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
121
Assets/External/TextMesh Pro/Examples & Extras/Scripts/TextConsoleSimulator.cs
vendored
Normal file
121
Assets/External/TextMesh Pro/Examples & Extras/Scripts/TextConsoleSimulator.cs
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TextConsoleSimulator : MonoBehaviour
|
||||
{
|
||||
private TMP_Text m_TextComponent;
|
||||
private bool hasTextChanged;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
m_TextComponent = gameObject.GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(RevealCharacters(m_TextComponent));
|
||||
//StartCoroutine(RevealWords(m_TextComponent));
|
||||
}
|
||||
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
// Subscribe to event fired when text object has been regenerated.
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
|
||||
// Event received when the text object has changed.
|
||||
void ON_TEXT_CHANGED(Object obj)
|
||||
{
|
||||
hasTextChanged = true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method revealing the text one character at a time.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerator RevealCharacters(TMP_Text textComponent)
|
||||
{
|
||||
textComponent.ForceMeshUpdate();
|
||||
|
||||
TMP_TextInfo textInfo = textComponent.textInfo;
|
||||
|
||||
int totalVisibleCharacters = textInfo.characterCount; // Get # of Visible Character in text object
|
||||
int visibleCount = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (hasTextChanged)
|
||||
{
|
||||
totalVisibleCharacters = textInfo.characterCount; // Update visible character count.
|
||||
hasTextChanged = false;
|
||||
}
|
||||
|
||||
if (visibleCount > totalVisibleCharacters)
|
||||
{
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
visibleCount = 0;
|
||||
}
|
||||
|
||||
textComponent.maxVisibleCharacters = visibleCount; // How many characters should TextMeshPro display?
|
||||
|
||||
visibleCount += 1;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method revealing the text one word at a time.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerator RevealWords(TMP_Text textComponent)
|
||||
{
|
||||
textComponent.ForceMeshUpdate();
|
||||
|
||||
int totalWordCount = textComponent.textInfo.wordCount;
|
||||
int totalVisibleCharacters = textComponent.textInfo.characterCount; // Get # of Visible Character in text object
|
||||
int counter = 0;
|
||||
int currentWord = 0;
|
||||
int visibleCount = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
currentWord = counter % (totalWordCount + 1);
|
||||
|
||||
// Get last character index for the current word.
|
||||
if (currentWord == 0) // Display no words.
|
||||
visibleCount = 0;
|
||||
else if (currentWord < totalWordCount) // Display all other words with the exception of the last one.
|
||||
visibleCount = textComponent.textInfo.wordInfo[currentWord - 1].lastCharacterIndex + 1;
|
||||
else if (currentWord == totalWordCount) // Display last word and all remaining characters.
|
||||
visibleCount = totalVisibleCharacters;
|
||||
|
||||
textComponent.maxVisibleCharacters = visibleCount; // How many characters should TextMeshPro display?
|
||||
|
||||
// Once the last character has been revealed, wait 1.0 second and start over.
|
||||
if (visibleCount >= totalVisibleCharacters)
|
||||
{
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
}
|
||||
|
||||
counter += 1;
|
||||
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user