Audio Dialogue on Hover

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Albyd
Posts: 29
Joined: Thu Jul 21, 2022 4:46 pm

Audio Dialogue on Hover

Post by Albyd »

HI again!
looking at the forum, I noticed that playing a specific audio entry on hover to represent thoughts has been treated already, but unfortunately, the suggested solution is giving me an error.

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.DialogueSystem;
using PixelCrushers;
using UnityEngine.UI;

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);
    }
}
I'm using this bit of code here, then connecting the event on the button responses and fire it when hovering.
However.. i'm getting that respondeButton doesn't exist in the current context error.

Is there a new way of doing it?
Thanks!
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Audio Dialogue on Hover

Post by Tony Li »

Hi,

The example you're looking at uses the older UI scripts. Try changing:

Code: Select all

var response = GetComponent<UnityUIResponseButton>().response;
to:

Code: Select all

var response = GetComponent<StandardUIResponseButton>().response;
Albyd
Posts: 29
Joined: Thu Jul 21, 2022 4:46 pm

Re: Audio Dialogue on Hover

Post by Albyd »

Thanks!
Unfortunately, even with your suggestion, the error persists.
Attachments
error.png
error.png (36.48 KiB) Viewed 744 times
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Audio Dialogue on Hover

Post by Tony Li »

Hi,

That's a different error. Change the red underlined "responseButton.dialogueEntry" to "response.destinationEntry".
Albyd
Posts: 29
Joined: Thu Jul 21, 2022 4:46 pm

Re: Audio Dialogue on Hover

Post by Albyd »

Ok, now it's the script is not giving me any more errors.
However, if i put the script on the buttons, i get "NullReferenceException: Object reference not set to an instance of an object
HoverButton.PlayHoverSequence () (at Assets/HoverButton.cs:17)"
Where do you suggest putting the script?

Just in case, here's some screenshots
Attachments
HoverButton.png
HoverButton.png (292.81 KiB) Viewed 722 times
button_hover_2.png
button_hover_2.png (243.1 KiB) Viewed 722 times
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Audio Dialogue on Hover

Post by Tony Li »

Do your buttons have StandardUIResponseButton components? That's a requirement for dialogue UIs. Those StandardUIResponseButton components should be assigned to the StandardUIMenuPanel component's Buttons list. See: Dialogue UIs (video tutorials)
Albyd
Posts: 29
Joined: Thu Jul 21, 2022 4:46 pm

Re: Audio Dialogue on Hover

Post by Albyd »

Yes, buttons are connected to the button panel.
I kind of have no idea why it doesn't work ahah
Attachments
screenshot.png
screenshot.png (419.88 KiB) Viewed 697 times
User avatar
Tony Li
Posts: 22148
Joined: Thu Jul 18, 2013 1:27 pm

Re: Audio Dialogue on Hover

Post by Tony Li »

Do the scripts show any red-underlined errors?

Can you send a reproduction project to tony (at) pixelcrushers.com?

Can you look at the Hover Example (direct download) available on the Dialogue System Extras page?
Post Reply