Page 1 of 1
Is there an event which fires when player chooses a response
Posted: Tue Feb 19, 2019 12:12 pm
by DragoonHP
Can't find any such event in here >
https://www.pixelcrushers.com/dialogue_ ... pting.html
Closest is OnConversationResponseMenu but it fires when the player is shown the menu
Re: Is there an event which fires when player chooses a response
Posted: Tue Feb 19, 2019 12:21 pm
by Tony Li
Try OnConversationLine. Even if the player's response isn't shown again as a subtitle, OnConversationLine will still be called.
Re: Is there an event which fires when player chooses a response
Posted: Wed Feb 20, 2019 12:26 am
by DragoonHP
I wanted to know when the player clicks on a response. Is there a way to know that?
Re: Is there an event which fires when player chooses a response
Posted: Wed Feb 20, 2019 9:52 am
by Tony Li
OnConversationLine
will be called when the player clicks on a response. Example:
Code: Select all
public class OnConversationLine(Subtitle subtitle) {
if (subtitle.speakerInfo.isPlayer) Debug.Log("Player chose: " + subtitle.formattedText.text);
}
Another way is to add to the OnClick() event of the response button(s). For example, you could add a script like this:
Code: Select all
public class LogWhenClicked : MonoBehaviour {
void Awake() {
GetComponent<UnityEngine.UI.Button>().onClick.AddListener(OnClick);
}
void OnClick() {
var response = GetComponent<StandardUIResponseButton>().response;
Debug.Log("Clicked: " + response.formattedText.text);
}
}
The code above adds to the OnClick() event in code, but if you prefer you could instead assign it in the inspector.
Re: Is there an event which fires when player chooses a response
Posted: Wed Feb 20, 2019 10:43 am
by DragoonHP
Thanks.
