I’m getting the errors:
1- Assets\scripts\Player\DialogueObject.cs(39,17): error CS0103: The name ‘curDialogue’ does not exist in the current context
for (39,17), (56,13), (59,26)
2- Assets\scripts\Player\DialogueObject.cs(15,25): warning CS0414: The field ‘DialogueOBJ.curDialogue’ is assigned but its value is never used
3- Assets\scripts\Player\DialogueObject.cs(48,13): error CS0103: The name ‘currentDialogueNum’ does not exist in the current context
for (48,13), (56,13), (59,26)
4- Assets\scripts\Player\DialogueObject.cs(14,17): warning CS0414: The field ‘DialogueOBJ.currentDialogueNum’ is assigned but its value is never used
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
[SerializeField]
public class DialogueOBJ
{
public string[] Dialogues;
public string CharacterName;
public int questNumber;
// Where the variables are defined
private int currentDialogueNum = 0;
private DialogueOBJ curDialogue = null;
}
public class DialogueObject : MonoBehaviour
{
private PlayerData data;
public TextMeshProUGUI nameText;
public TextMeshProUGUI DialogueText;
[Header("Dialogue objects")]
public DialogueOBJ dialogue1;
private void Start()
{
data = FindObjectOfType<PlayerData>();
}
private void OnEnable()
{
switch (data.DialogueNumber)
{
case 1:
PlayDialogue(dialogue1);
curDialogue = dialogue1; // one of the errors saying the variable isn't defined
break;
}
}
void PlayDialogue(DialogueOBJ tempobj)
{
nameText.text = tempobj.CharacterName;
if (currentDialogueNum < tempobj.Dialogues.Length) // one of the errors saying the variable in't defined
{
DialogueText.text = tempobj.Dialogues[currentDialogueNum]; // one of the errors saying that the variable isn't defined
}
}
public void next()
{
if (curDialogue != null) // one of the errors saying the variable isn't defined
{
currentDialogueNum++; // one of the errors saying that the variable isn't defined
PlayDialogue(curDialogue); // one of the errors saying the variable isn't defined
}
else
{
//end
}
}
}
What I have done and tried:
I have gone through and made sure each instance was spelled correctly and even copied the definition version and pasted it in each instance.
I have tried to see if changing them from private to public but was still getting the same errors so I changed them back.
I’m still new to using Unity and C# both. This code is from a tutorial that I’m doing but has stopped me from moving on. Any help would be appreciated. Thank You.