Change selected answer Color & Call "Start Conversation" via script?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Terraya
Posts: 19
Joined: Sat Feb 01, 2020 5:22 pm

Change selected answer Color & Call "Start Conversation" via script?

Post by Terraya »

Hey There again!

Thank you for the last answer, i would like to ask 2 questions:

1. Where can i change the "selected answer button" (the view of) , becouse i changed mine
into text no background etc .. but if i hover my mouse over it , it shows the background and so on ...

i hope you can follow me, if not i can send pictures and try to explain,

2. I got my own Character Selection Script , so is there any way to call the "start conversation" function via. my script instead of the DIalogue Manager?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change selected answer Color & Call "Start Conversation" via script?

Post by Tony Li »

Hi,
Terraya wrote: Tue Feb 04, 2020 4:42 pm 1. Where can i change the "selected answer button" (the view of) , becouse i changed mine into text no background etc .. but if i hover my mouse over it , it shows the background and so on ...
Inspect the response button. In the dialogue UI, this is a child GameObject fairly deep in the hierarchy, typically named something like 'Response Button Template'. Remove the Image component from it. You may want to assign the button's Text component (which is probably on a child GameObject) to the Button's 'Target Graphic' field. You can also set the colors that the Button will use for the text in various states, such as Normal (not selected) and Highlighted (player has moused over the button).
Terraya wrote: Tue Feb 04, 2020 4:42 pm 2. I got my own Character Selection Script , so is there any way to call the "start conversation" function via. my script instead of the DIalogue Manager?
Sure! Use DialogueManager.StartConversation("title", actorTransform, conversantTransform). The actorTransform and conversantTransform are optional. For example:

Code: Select all

using PixelCrushers.DialogueSystem; //<-- Add to top of script.
...
DialogueManager.StartConversation("My Conversation");
Terraya
Posts: 19
Joined: Sat Feb 01, 2020 5:22 pm

Re: Change selected answer Color & Call "Start Conversation" via script?

Post by Terraya »

Alright super!

i aktualy removed the "Text" component unter the "Response Button" and i addet a "Text" Component to the "Response Button" so it work perfekt as i want, thank you alot!

another question is:

- to Start a conversation, do i need a selector component?

What i am doing atm is, sending a raycast infront of my Player Object, if the target is closer then "xxx distance", i can fokus on it so the Player fokus on the target object, if i start interaction, i get its component (a custom Component "Interactable"), so to use the "Dialogue System" made by PixelCrushers , what would be the best approach to start a Interaction with the fokused target?

As i mentioned before, english is not my native language, if you cant follow me i can provide pictures visualitze what i mean,

thanks already for your great help!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change selected answer Color & Call "Start Conversation" via script?

Post by Tony Li »

Hi,

There are 2 good ways to start a conversation via script:

1. Add a Dialogue System Trigger to the target object. Call the Dialogue System Trigger's OnUse() method in script:

Code: Select all

targetObject.GetComponent<DialogueSystemTrigger>().OnUse();
2. Or use DialogueManager.StartConversation("title") in script:

Code: Select all

DialogueManager.StartConversation("My Conversation");
Terraya
Posts: 19
Joined: Sat Feb 01, 2020 5:22 pm

Re: Change selected answer Color & Call "Start Conversation" via script?

Post by Terraya »

Perfect!

thats worked out so far ,

is there any possibility to detect if the User finished the conversation with the NPC and then send a Function or event after it?

I have a state machine and my Entitys decision making depends on the state machine (Patroling/JobSystem/Combat/Interact and so on ... ) ,

so when the Player and the NPC starts to have a conversation the state machine goes to a certain state and after i finish the conversation i would like to set the state back (call a specific function or event) ..

i hope you can follow me,
thank you again very much for your help!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change selected answer Color & Call "Start Conversation" via script?

Post by Tony Li »

Hi,

Yes, you can add a script to the Dialogue Manager or one of the participants that has an OnConversationEnd method. Or add a Dialogue System Events, which does the same thing but as UnityEvents that you can hook up in the inspector. Or you can check DialogueManager.isConversationActive. But it's probably more efficient to use the script method or Dialogue System Events instead of constantly polling DialogueSystem.isConversationActive.
Terraya
Posts: 19
Joined: Sat Feb 01, 2020 5:22 pm

Re: Change selected answer Color & Call "Start Conversation" via script?

Post by Terraya »

Hey there,

thank you very much for answering my questions,

So i would love to use "OnConversationEnd" since thats the Method which is most practical for me i think.

Can i use this function like "OnApplicationQuit/OnApplicationPause/OnApplicationResume" etc.. as a function which get automaticaly called after the event happen?

If Yes, great! But i cant find it, i went through serveral scripts and i cant find the function or any way to use it.

Obv. i could use "isConversationActive" but i woud like to avoid it if its possible


OK EDIT: Thanks for your help, i just found it out x)
i was just a bit stupid :D , thanks alot!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change selected answer Color & Call "Start Conversation" via script?

Post by Tony Li »

Glad to help! :-)
Post Reply