Set’s the conversation index for the NPC Number defined.

The Chat Manager is used by NPC Chat objects configured with a Structured Chat Type. Since it’s a ScriptableObject, it can be referenced by any object from any scene, allowing for NPC Chat objects to have their conversations to use to be set from any scene.

ScriptableObject Location:

Assets\TurnTheGameOn\NPC Chat\Data\ChatManager.asset

Inspector Variables:

Variable Description
Player Name A cached reference to the player name stored in PlayerPrefs.
Delete Player Name From PlayerPrefs Button Deletes the currently stored player name from PlayerPrefs.
NPC Indexes Allows you to create a unique conversation index for each NPC that uses this Chat Manager. Each NPC Conversation index will be used by an NPC object that has a matching NPC Number assigned. Pressing the update button will update the available indexes.
NPC Conversation Indexes Holds a reference to the conversation index that an NPC configured with Structured Chat Type should use.

Using the Chat Manager

You can access and edit this object’s current conversation values either via code in your own scripts, or via the NPC Chat objects in the inspector.

Scripting with the Chat Manager

There are 2 Chat Manager methods that you may want to use with your own custom scripts. Make sure you’re using the TurnTheGameOn.NPCChat namespace to access the Chat Manager.

Example:

SetConversationIndexForNPC (int npcNumber, int conversationNumber)
Sets the conversation index number for an NPC.
SetPlayerName (string playerName)
Sets the string used for the player’s name when the markup tag is used inside NPC Chat dialogue text.

Unity Inspector Events with the Chat Manager

Unity inspector events only allow for a single variable to be passed to a scripting method, to support this the SetConversationIndexForNPC method listed above was broken into 2 methods SetNPCNumberToEdit and SetNewConversationForNPC that will need to be called sequentially.

SetNPCNumberToEdit (int npcNumber)
Sets the npc number to edit with the SetNewConversationForNPC method.
SetNewConversationForNPC (int conversationNumber)
Sets the conversation for the currently set npc number.

Inspector Event Sample:

Complete Configuration of Inspector Event Sample:

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Please do not use this for support questions.
For customer support, please contact us here.

Post Comment