Word Detection

About Word Detection – Unity Editor Tool & Plugin

Word Detection Unity Asset Overview

The Word Detection package is structured as a decoupled, event-driven pattern-matching tool that bridges textual or phonetic input sequences with active Character Controllers and the Unity Animator state machine. Rather than relying on simple string comparisons at runtime—which introduce significant garbage collection overhead—this asset implements a trie-based search tree or pre-hashed token matching system to parse inputs instantly.

Data Architecture & ScriptableObjects

At the core of the system is the WordDatabase, a ScriptableObject that stores dictionaries of tracked phrases, key sequences, or phoneme structures. By isolating vocabulary definitions in serialized containers, the runtime architecture keeps data separated from logic. Each entry in the database associates a specific text key with a corresponding animation state, gameplay trigger, or event payload.

Because dynamic string concatenation and sub-string allocation generate high amounts of garbage collection (GC) in Unity, the system utilizes pre-allocated buffers and integer-based hashing (using Animator.StringToHash) to transition character states. When a sequence is registered, the engine parses it using a lightweight state machine that avoids heap allocation entirely during gameplay loops.

Event-Driven Pattern-Matching Logic

The integration architecture relies on delegation. The WordDetectionEngine processes characters or tokens sequentially and notifies registered listeners through standard C# actions instead of costly SendMessage or broadcast systems. This allows the character controller to dynamically switch animation parameters or state machines based on textual prompts or keyboard input sequences.

using System;
using UnityEngine;

namespace WordDetection.Core
{
    public class WordDetectionEngine : MonoBehaviour
    {
        [SerializeField] private WordDatabase wordDatabase;
        
        public event Action<int> OnWordDetected; // Passes the Animator parameter hash

        private string _inputBuffer = string.Empty;

        public void RegisterInputToken(char token)
        {
            _inputBuffer += token;
            EvaluateBuffer();
        }

        private void EvaluateBuffer()
        {
            if (wordDatabase.TryMatch(_inputBuffer, out int animationTriggerHash))
            {
                OnWordDetected?.Invoke(animationTriggerHash);
                ClearBuffer();
            }
        }

        public void ClearBuffer()
        {
            _inputBuffer = string.Empty;
        }
    }
}
---

Inspector Configuration & Workflow

The system provides highly customized Editor tools to clean up workflow pipelines within the Unity Inspector. This mitigates the complexity of aligning string-based inputs with character movement states, preventing runtime failures caused by simple typos.

Custom Property Drawers & Validation

The asset includes a specialized WordDatabaseEditor interface that validates input sequences in real-time. When setting up word-to-animation linkages, the Inspector queries the referenced AnimatorController. It then displays available animation states as dropdown selections rather than text fields, eliminating manual entry mistakes.

Configuring the Manager Prefab

To implement the system, a single WordDetectionManager prefab must reside within the active scene hierarchy. This manager acts as the structural facade, receiving inputs from sources such as UI InputFields, direct keystrokes, or speech-to-text parsers, and routing processed tokens directly to character execution scripts.

---

Quick-Start Unity Integration Guide

Follow these structural integration steps to connect the word parser system with a character controller and trigger physical animations.

Step 1: Set Up the Word Database

Right-click in your Project window and select Create > Word Detection > Word Database. Name the asset DefaultVocabulary. In the Inspector, add a new element with the keyword "jump" and assign the target parameter hash or Animator trigger to match your character's jump animation trigger.

Step 2: Place the Engine Manager

Drag the WordDetectionManager prefab into your active Unity Scene hierarchy. Ensure it has a reference to the DefaultVocabulary database created in Step 1.

Step 3: Connect the Character Controller Script

Create a script named CharacterAnimationBridge and attach it to your character GameObject. This script listens to the detection event and transitions your animator state efficiently.

using UnityEngine;
using WordDetection.Core;

[RequireComponent(typeof(Animator))]
public class CharacterAnimationBridge : MonoBehaviour
{
    [SerializeField] private WordDetectionEngine detectionEngine;
    private Animator _animator;

    private void Awake()
    {
        _animator = GetComponent<Animator>();
    }

    private void OnEnable()
    {
        if (detectionEngine != null)
        {
            detectionEngine.OnWordDetected += HandleWordDetected;
        }
    }

    private void OnDisable()
    {
        if (detectionEngine != null)
        {
            detectionEngine.OnWordDetected -= HandleWordDetected;
        }
    }

    private void HandleWordDetected(int animatorParamHash)
    {
        // Executes transition utilizing pre-hashed integer values for optimal performance
        _animator.SetTrigger(animatorParamHash);
    }
}
---

Performance Analysis & Runtime Footprint

When deploying games to resource-constrained systems such as mobile, standalone VR, or consoles, processing strings in real-time can impact frame-rate consistency. The architectural design of this asset minimizes common performance bottlenecks.

GC Allocations & Memory Footprint

Standard string comparison methods such as string.StartsWith() or string.Substring() generate heap allocations that force garbage collection cycles. To this overhead, this tool uses key structural design practices:

IL2CPP Compilation Compatibility

The code is fully compatible with Ahead-Of-Time (AOT) compilation used by IL2CPP targets. Because it avoids aggressive runtime reflection to lookup animations and parameters, there is no risk of stripped bytecode crashes during shipping builds.

---

Asset Details & Specifications

CategoryTools / Integration
Latest Versionv1.11
File Size132.27 MB
Added to PlatformFebruary 5, 2026
Views1 views
Downloads0 downloads
Favourites0 favourites
Issue with Package?Report Broken Link →

Related Unity Tools Assets