Page 1 of 1

Audio Dialogue on Hover

Posted: Fri May 24, 2024 8:43 am
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!

Re: Audio Dialogue on Hover

Posted: Fri May 24, 2024 9:52 am
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;

Re: Audio Dialogue on Hover

Posted: Fri May 24, 2024 11:52 am
by Albyd
Thanks!
Unfortunately, even with your suggestion, the error persists.

Re: Audio Dialogue on Hover

Posted: Fri May 24, 2024 12:20 pm
by Tony Li
Hi,

That's a different error. Change the red underlined "responseButton.dialogueEntry" to "response.destinationEntry".

Re: Audio Dialogue on Hover

Posted: Fri May 24, 2024 12:32 pm
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

Re: Audio Dialogue on Hover

Posted: Fri May 24, 2024 2:14 pm
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)

Re: Audio Dialogue on Hover

Posted: Sat May 25, 2024 6:39 am
by Albyd
Yes, buttons are connected to the button panel.
I kind of have no idea why it doesn't work ahah

Re: Audio Dialogue on Hover

Posted: Sat May 25, 2024 9:14 am
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?