Playing dialogue audio on selection
Playing dialogue audio on selection
I was wondering if there was a way to get audio clips to play if I just hover and highlight a dialogue option? I have my character speaking his thoughts depending on what he highlights in the selection during a conversation? if there is a way could you let me know? Thanks! Love using your system btw!
Re: Playing dialogue audio on selection
Hi,
Yes, but it requires a little scripting. I'll describe one possible approach using Unity UI. If you're using a different GUI system, you can adapt the same idea.
In your dialogue database, add a custom field titled something like "Hover Sequence" to your response dialogue entry notes. Set it to a sequence such as "Audio(someThoughtsAudioClip)" where someThoughtsAudioClip is the name of an audio clip in a Resources folder.
Create a script with a method such as "PlayHoverSequence" and add it to your response buttons (or your response button template if you're using that style).
Add an Event Trigger component to the response button. Add a Pointer Enter event, and assign the PlayHoverSequence method.
How this works:
1. When the player hovers over the button, the Event Trigger > Pointer Enter event calls the PlayHoverSequence method.
2. The PlayHoverSequence method looks up the response associated with the button and plays its Hover Sequence.
Yes, but it requires a little scripting. I'll describe one possible approach using Unity UI. If you're using a different GUI system, you can adapt the same idea.
In your dialogue database, add a custom field titled something like "Hover Sequence" to your response dialogue entry notes. Set it to a sequence such as "Audio(someThoughtsAudioClip)" where someThoughtsAudioClip is the name of an audio clip in a Resources folder.
Create a script with a method such as "PlayHoverSequence" and add it to your response buttons (or your response button template if you're using that style).
Code: Select all
public class HoverButton : MonoBehaviour {
public void PlayHoverSequence() {
// Get the response associated with the button:
var response = GetComponent<UnityUIResponseButton>().response;
// Set the response's Hover Sequence:
var sequence = Field.LookupValue(responseButton.dialogueEntry.fields, "Hover Sequence");
// Play the Hover Sequence:
DialogueManager.PlaySequence(sequence);
}
}
How this works:
1. When the player hovers over the button, the Event Trigger > Pointer Enter event calls the PlayHoverSequence method.
2. The PlayHoverSequence method looks up the response associated with the button and plays its Hover Sequence.