Announcements, support questions, and discussion for the Dialogue System.
tabtaste
Posts: 16 Joined: Fri Oct 07, 2022 11:46 am
Post
by tabtaste » Wed Nov 23, 2022 10:49 am
Hey,
i want to show the actuel key binding from New input system as a turtorial with the Dialog Manager. I didnt find a good way. I tryed this but it dos not work.
is here a normal way to do it ?
Code: Select all
public void OnControlChanged()
{
playerInput = GetComponent<PlayerInput>();
inputActionJump = playerInput.actions["Jump"];
if (inputActionJump.GetBindingDisplayString() == null){ return; }
int i = 0;
foreach (var item in dialogDatabase.variables)
{
if (dialogDatabase.variables[i].Name == "JumpKey")
{
if (inputActionJump.GetBindingDisplayString() == null) { return; }
dialogDatabase.variables[i].InitialValue = inputActionJump.GetBindingDisplayString();
}
i++;
}
}
Tony Li
Posts: 22143 Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li » Wed Nov 23, 2022 11:48 am
Hi,
At runtime, think of the dialogue database as read-only. Don't change its variable's Initial Value. Instead, change the runtime value in the Lua environment using
DialogueLua.SetVariable() :
Code: Select all
public void OnControlChanged()
{
playerInput = GetComponent<PlayerInput>();
inputActionJump = playerInput.actions["Jump"];
if (inputActionJump.GetBindingDisplayString() == null){ return; }
DialogueLua.SetVariable("JumpKey", inputActionJump.GetBindingDisplayString());
}
Then you can use the [var=
variable ] markup tag in text:
Dialogue Text : "To jump, press [var=JumpKey]."
tabtaste
Posts: 16 Joined: Fri Oct 07, 2022 11:46 am
Post
by tabtaste » Wed Nov 23, 2022 11:56 am
WOW
thats grat!!!
can i also change the value "oncontrolchange" and refresh the text when i"m current in the dialog.
Something like "repeat/refresh current dialog subtitel text" with the new binding.
Tony Li
Posts: 22143 Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li » Wed Nov 23, 2022 2:11 pm
Hi,
Yes. Run this code:
Code: Select all
DialogueLua.SetVariable("JumpKey", inputActionJump.GetBindingDisplayString());
DialogueManager.currentConversationState.subtitle.formattedText =
FormattedText.Parse(DialogueManager.currentConversationState.subtitle.dialogueEntry.currentDialogueText);
DialogueManager.standardDialogueUI.ShowSubtitle(DialogueManager.currentConversationState.subtitle);
tabtaste
Posts: 16 Joined: Fri Oct 07, 2022 11:46 am
Post
by tabtaste » Thu Nov 24, 2022 3:11 am
thats great! thanks a lot !!!