I’m in a game design class and I’m working on a dialogue system following this tutorial.
Here’s the DialogueUI script (copied from the tutorial):
using System.Collections;
using UnityEngine;
using TMPro;
public class DialogueUI : MonoBehaviour
{
[SerializeField] private GameObject dialogueBox;
[SerializeField] private TMP_Text textLabel;
[SerializeField] private DialogueObject testDialogue;
private ResponseHandler responseHandler;
private TypewriterEffect typewriterEffect;
private void Start()
{
typewriterEffect = GetComponent<TypewriterEffect>();
responseHandler = GetComponent<ResponseHandler>();
CloseDialogueBox();
ShowDialogue(testDialogue);
}
public void ShowDialogue(DialogueObject dialogueObject)
{
dialogueBox.SetActive(true);
StartCoroutine(StepThroughDialogue(dialogueObject));
}
private IEnumerator StepThroughDialogue(DialogueObject dialogueObject)
{
for (int i = 0; i < dialogueObject.Dialogue.Length; i++)
{
string dialogue = dialogueObject.Dialogue[i];
yield return typewriterEffect.Run(dialogue, textLabel);
if (i = dialogueObject.Dialogue.Length - 1 && dialogueObject.HasResponses) break;
yield return new WaitUntil(() => Input.GetKeyDown(KeyCode.Space));
}
if (dialogueObject.HasResponses)
{
responseHandler.ShowResponses(dialogueObject.Responses);
}
else
{
CloseDialogueBox();
}
}
private void CloseDialogueBox()
{
dialogueBox.SetActive(false);
textLabel.text=string.Empty;
}
}
And here’s the error:
Assets\scripts\DialogueUI.cs(36,21): error CS0019: Operator ‘&&’ cannot be applied to operands of type ‘int’ and ‘bool’
I only have a few more days to work on this, and I have no idea how to fix this. Could someone please help?