Unity client features: - WebSocket connection via NativeWebSocket - 2.5D agent visuals with programmatic placeholder sprites - Billboard system for sprites and UI elements - Floating UI panels (name, HP, energy bars) - Speech bubble system with pop-in animation - RTS-style camera controller (WASD + scroll zoom) - Editor tools for prefab creation and scene setup Scripts: - NetworkManager: WebSocket singleton - GameManager: Agent spawning and event handling - AgentVisual: 2.5D sprite and UI creation - Billboard: Camera-facing behavior - SpeechBubble: Animated dialogue display - CameraController: RTS camera with UI input detection - UIManager: HUD and command input 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
74 lines
2.6 KiB
C#
Executable File
74 lines
2.6 KiB
C#
Executable File
using UnityEngine;
|
|
|
|
|
|
namespace TMPro.Examples
|
|
{
|
|
public class TMP_TextEventCheck : MonoBehaviour
|
|
{
|
|
|
|
public TMP_TextEventHandler TextEventHandler;
|
|
|
|
private TMP_Text m_TextComponent;
|
|
|
|
void OnEnable()
|
|
{
|
|
if (TextEventHandler != null)
|
|
{
|
|
// Get a reference to the text component
|
|
m_TextComponent = TextEventHandler.GetComponent<TMP_Text>();
|
|
|
|
TextEventHandler.onCharacterSelection.AddListener(OnCharacterSelection);
|
|
TextEventHandler.onSpriteSelection.AddListener(OnSpriteSelection);
|
|
TextEventHandler.onWordSelection.AddListener(OnWordSelection);
|
|
TextEventHandler.onLineSelection.AddListener(OnLineSelection);
|
|
TextEventHandler.onLinkSelection.AddListener(OnLinkSelection);
|
|
}
|
|
}
|
|
|
|
|
|
void OnDisable()
|
|
{
|
|
if (TextEventHandler != null)
|
|
{
|
|
TextEventHandler.onCharacterSelection.RemoveListener(OnCharacterSelection);
|
|
TextEventHandler.onSpriteSelection.RemoveListener(OnSpriteSelection);
|
|
TextEventHandler.onWordSelection.RemoveListener(OnWordSelection);
|
|
TextEventHandler.onLineSelection.RemoveListener(OnLineSelection);
|
|
TextEventHandler.onLinkSelection.RemoveListener(OnLinkSelection);
|
|
}
|
|
}
|
|
|
|
|
|
void OnCharacterSelection(char c, int index)
|
|
{
|
|
Debug.Log("Character [" + c + "] at Index: " + index + " has been selected.");
|
|
}
|
|
|
|
void OnSpriteSelection(char c, int index)
|
|
{
|
|
Debug.Log("Sprite [" + c + "] at Index: " + index + " has been selected.");
|
|
}
|
|
|
|
void OnWordSelection(string word, int firstCharacterIndex, int length)
|
|
{
|
|
Debug.Log("Word [" + word + "] with first character index of " + firstCharacterIndex + " and length of " + length + " has been selected.");
|
|
}
|
|
|
|
void OnLineSelection(string lineText, int firstCharacterIndex, int length)
|
|
{
|
|
Debug.Log("Line [" + lineText + "] with first character index of " + firstCharacterIndex + " and length of " + length + " has been selected.");
|
|
}
|
|
|
|
void OnLinkSelection(string linkID, string linkText, int linkIndex)
|
|
{
|
|
if (m_TextComponent != null)
|
|
{
|
|
TMP_LinkInfo linkInfo = m_TextComponent.textInfo.linkInfo[linkIndex];
|
|
}
|
|
|
|
Debug.Log("Link Index: " + linkIndex + " with ID [" + linkID + "] and Text \"" + linkText + "\" has been selected.");
|
|
}
|
|
|
|
}
|
|
}
|