[Fixed] Respon Not Working
Posted: Fri Nov 24, 2023 12:02 pm
Hi, I'm currently learning how to create my own custom dialogue UI using the Unity Nova UI asset. Everything is going well, but there is a slight problem with the responses. When I click one of the response buttons, the current status of the response does not happen anything.
https://youtu.be/2sWBREl79cg
The button itself is not a problem, it seems like I'm missing something.
Custom UI script using IDialogueUI
Script for responui
https://youtu.be/2sWBREl79cg
The button itself is not a problem, it seems like I'm missing something.
Custom UI script using IDialogueUI
Code: Select all
using UnityEngine;
using System;
using PixelCrushers.DialogueSystem;
using Nova;
using Unity.Mathematics;
public class HikmaUi : MonoBehaviour, IDialogueUI
{
public GameObject dialouePanel;
public TextBlock dialogueText;
public TextBlock speakterName;
public UIBlock2D actorPotraitPanel;
public event EventHandler<SelectedResponseEventArgs> SelectedResponseHandler;
public bool isItalic;
public bool isPlay;
public Transform dialoguePosition;
public GameObject responPanel;
public GameObject ButonExample;
public GameObject rootRespon;
public void Open()
{
dialouePanel.SetActive(true);
}
public void Close()
{
// Add your code here to do any cleanup at the end of a conversation -- for example,
// deactivating GUI controls.
transform.position = Vector3.one;
isPlay = false;
dialouePanel.SetActive(false);
}
public void ShowSubtitle(Subtitle subtitle)
{
if (isPlay == false)
{
transform.position = subtitle.speakerInfo.transform.position + new Vector3(0,2,0);
isPlay = true;
}
actorPotraitPanel.SetImage(subtitle.GetSpeakerPortrait());
//Debug.Log();
speakterName.Text = subtitle.speakerInfo.Name;
dialogueText.Text = subtitle.formattedText.text;
// Add your code here to show a subtitle. Subtitles contain information such as the player
// type (PC or NPC), portrait texture, and the formatted text of the line.
}
public void HideSubtitle(Subtitle subtitle)
{
}
public void ShowResponses(Subtitle subtitle, Response[] responses, float timeout)
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
for (int i = 0; i < responses.Length; i++)
{
GameObject responDesu = Instantiate(ButonExample, rootRespon.transform);
HikmaRespon hikmaRespon = responDesu.GetComponent<HikmaRespon>();
hikmaRespon.response = responses[i];
hikmaRespon.text = responses[i].formattedText.text;
}
responPanel.SetActive(true);
// Add your code here to show the player response menu. Populate the menu with the contents
// of the responses array. When the player selects a response, call:
// SelectedResponseHandler(this, new SelectedResponseEventArgs(response));
// where the argument "response" is the response that the player selected.
// If (timeout > 0), auto-select a response when timeout seconds have passed.
}
public void HideResponses()
{
// Add your code here to hide the player response menu.
responPanel.SetActive(false);
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
public void ShowQTEIndicator(int index)
{
/// Add your code here to show the Quick Time Event (QTE) indicator specified by the given
/// index. If your project doesn't use QTEs, you can leave this method empty.
}
public void HideQTEIndicator(int index)
{
/// Add your code here to hide the Quick Time Event (QTE) indicator specified by the given
/// index. If your project doesn't use QTEs, you can leave this method empty.
}
public void ShowAlert(string message, float duration)
{
// Add your code here to show an alert message. Note that the dialogue system will not
// call Open() or Close() for alerts, since alerts are meant to be shown outside of
// conversations.
}
public void HideAlert()
{
// Add your code here to hide the alert message if it's showing.
}
}
Code: Select all
using Nova;
using PixelCrushers.DialogueSystem;
using UnityEngine;
using UnityEngine.EventSystems;
public class HikmaRespon : MonoBehaviour
{
// Start is called before the first frame update
public virtual Response response { get; set; }
public TextBlock labelText;
public virtual string text
{
set
{
labelText.Text = value;
}
}
public void SetRespon()
{
if (DialogueManager.instance.conversationController != null)
{
DialogueManager.instance.conversationController.SetCurrentResponse(response);
Debug.LogWarning("Button press");
}else
{
Debug.LogWarning("Null");
}
}
}