Neocortex
IntegrationsUnity SDK

UI Elements

The chat UI that ships with the Neocortex Unity SDK

The SDK ships a complete chat interface, so a talking character needs no UI code of your own. Right click the Hierarchy, choose Neocortex > Complete Text Chat or Complete Voice Chat, and the whole rig is placed and wired for you.

Neocortex Unity SDK UI Elements

Both entries build the whole rig: canvas, chat panel, input, thinking indicator, and a wired character. To assemble something different, scaffold one of them and delete or rearrange the parts you do not want, or add the components below to your own canvas by hand.

The binders

Two components run the conversation loop: input in, bubbles out, thinking indicator, microphone handoff, history and errors. Which one you use depends on whether the scene has one character or a cast.

ComponentUse it forPairs with
NeocortexChatUIOne characterNeocortexSmartAgent
NeocortexGroupChatUIA whole castNeocortexGroupDirector

One binder per scene

In a group scene put a single NeocortexGroupChatUI on the director. Do not also put a NeocortexChatUI on each character, or every reply is printed once per UI.

Both expose the same fields, and every widget reference is optional and auto resolved from the GameObject's children. Leave one empty and that feature is simply skipped, so the same component serves text only, voice only and mixed setups.

FieldDescription
Agent or DirectorWho the UI talks to.
Player NameThe name on the player's own messages, used for the avatar's initial.
Chat PanelThe transcript.
Text Chat InputTyped input.
Audio Chat InputThe record button.
Thinking IndicatorShown while the character composes.
Voice InputThe microphone.

Every field is public, so you can wire one from code just as well:

Chat UI Example
// Everything is optional, this is the whole setup for a working chat
var ui = gameObject.AddComponent<NeocortexChatUI>();
ui.agent = myAgent;
ui.playerName = playerProfile.displayName;

Binding the microphone switches the agent's Auto Voice Input off, so the player's speech is never sent twice.


Chat Panel

NeocortexChatPanel draws the transcript. It inherits from ScrollRect, so messages scroll. Messages carry a sender name, which becomes the avatar's initial, so in a group scene it is obvious who said what.

Chat panel with avatars

Methods

AddMessage

Adds a message bubble to the panel.

  • Parameters:
    • sender: The name shown on the bubble, and the letter on its avatar. Pass null or an empty string for no avatar. There is a shorthand overload without this parameter.
    • text: The message to display.
    • isUser: true for the player's own message, which changes the alignment and colours.
    Chat Panel Example
    var chatPanel = GetComponent<NeocortexChatPanel>();
    chatPanel.AddMessage("Aria", "Well met, traveller.", false);
    chatPanel.AddMessage("You", "Where am I?", true);
    chatPanel.AddMessage("Something happened.", false); // no sender, no avatar

ClearMessages

Removes every bubble from the panel.

ClearMessages Example
chatPanel.ClearMessages();

Right to left languages

writingDirection flips both the text and the alignment of the messages. Set it in the inspector or from code when the character speaks Arabic, Hebrew, Urdu or Persian.

Writing Direction Example
chatPanel.writingDirection = WritingDirection.RightToLeft;
chatPanel.AddMessage("مرحبا، كيف حالك؟", true);

Inspector

FieldDescription
Display AvatarsShow a small avatar with the sender's initial beside each message.
Message ColorsBackground and text colour for the player and for characters.
Message Item PrefabYour own NeocortexMessage prefab, to restyle every bubble. Leave empty for the built in one.
Font OverwriteApply one font across the transcript.

A custom message prefab without an Avatar object simply shows no avatar, so older prefabs keep working.


Text Chat Input

An input field with a send button.

Text Chat Input

Events

OnSendButtonClicked

Raised when the send button is clicked, or the player presses return.

  • Arguments:
    • message: The text the player entered.
    Text Chat Input Example
    var textChatInput = GetComponent<NeocortexTextChatInput>();
    textChatInput.OnSendButtonClicked.AddListener((message) =>
    {
        agent.TextToText(message);
    });

Audio Chat Input

A record button bound to an audio receiver. It shows a recording state while the microphone is live and a waiting state while the character answers.

Audio Chat Input

From left to right:

  • Amplitude Indicator: Shows the level of the audio input.
  • Microphone Timer: Counts down the wait before recording stops on its own.
  • Push To Talk Button: Held down to record.

In push to talk mode the player holds the button to record, and the message is sent when they release it.

In voice activity mode recording starts when the player starts speaking and stops when they stop.

Either way, the transcript of what they said is printed in the chat panel.

Methods

SetChatState

Switches the widget between its recording and waiting states. The binders call it for you, so you only need it when you drive the microphone yourself.

  • Parameters:
    • isRecording: true while the microphone is live, false while the character answers.
    Audio Chat Input Example
    audioInput.voiceInput = myAudioReceiver;
    audioInput.SetChatState(false); // lock the button while the character replies

Thinking Indicator

Shows a loading animation while the character is composing. In Text chat lines mode the binders also show it during the pause between lines, so the gap reads as the character typing. See chat lines.

Thinking Indicator

Methods

Display

Shows or hides the thinking indicator.

  • Parameters:
    • isVisible: true to show it, false to hide it.
    Thinking Indicator Example
    var thinkingIndicator = GetComponent<NeocortexThinkingIndicator>();
    thinkingIndicator.Display(true);

Microphone Dropdown

Lists the available input devices and remembers the choice, so players can switch microphone in game. It reads and writes the same selection as NeocortexAudioReceiver, so no wiring is needed.

Microphone Dropdown


Push To Talk Button

A button that reports being held rather than clicked, used by the Audio Chat Input in push to talk mode.

Events

OnButtonPressed

Raised when the player presses the button down.

OnButtonReleased

Raised when the player lets go.

Push To Talk Example
pushToTalkButton.OnButtonPressed.AddListener(() => mic.StartMicrophone());
pushToTalkButton.OnButtonReleased.AddListener(() => mic.StopMicrophone());

On this page