Why is my DialogueBoxObject not recognizing its dialogue?
I'm following a Visual Novel tutorial. I made an editor so I could easily change the dialogue and now I want it to be displayed on the screen when I start it. Now I added a public string dialogue in the DialogueBox class, and in the DialogueParser class I made the connection between the program and the text. I just can't find my mistake. I'm really bad at explaining, so here in short: Where I underlined in the Picture: It should Display some text from my text file Dialogue1.txt, but ist just empty and I don't know why. I would really appreciate it if you could help me!
Here's my code so far:
DialogueParser class
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 using System.Text;
 using System.IO;
 using System.Text.RegularExpressions;
 using UnityEditor.SceneManagement;
 using System.Collections.Concurrent;
 using System.Linq;
 
 public class DialogeParser : MonoBehaviour
 {
     List<DialogueLine> lines;
         
 
     struct DialogueLine
     {
         public string name;
         public string content;
         public int pose;
 
         public DialogueLine (string n, string c,int p )
         {
             name = n;
             content = c;
             pose = p;
         }
     }
     // Start is called before the first frame update
     void Start()
     {
         string file = "Dialogue1";
         string sceneNum = EditorSceneManager.GetActiveScene().name;
         sceneNum = Regex.Replace(sceneNum, "(^ 0 - 9)", ""); // 1
         file += sceneNum; // file + SceneNum = Dialogue 1
         file += ".txt";
         lines = new List<DialogueLine>();
         LoadDialogue(file);
     }
 
     // Update is called once per frame
     void Update()
     {
         
     }
 
     public string GetName(int lineNumber)
     {
         if (lineNumber < lines.Count)
             return lines[lineNumber].name;
 
         return "";
     }
 
     public string GetContent(int lineNumber)
     {
         if (lineNumber < lines.Count)
             return lines[lineNumber].content;
 
         return "";
     }
 
     public int GetPose(int lineNumber)
     {
         if (lineNumber < lines.Count)
             return lines[lineNumber].pose;
 
         return 0;
     }
     void LoadDialogue(string filename)
     {
         string file = "Asset/Resources/" + filename;
         string line;
         StreamReader r = new StreamReader(file);
         using (r)
         {
             do
             {
                 line = r.ReadLine();
                 if (line!=null)
                 {
                     string[] line_values = SplitCsvLine (line);
                     DialogueLine line_entry = new  DialogueLine(line_values[0], line_values[1],int.Parse(line_values[2]));
                     lines.Add(line_entry);
                         
                 }
             }
             while (line != null);
             r.Close();
         }
     }
 
     // splits a CSV row 
     private string[] SplitCsvLine(string line)
     {
         string pattern = @"
      # Match one value in valid CSV string.
      (?!\s*$)                                      # Don't match empty last value.
      \s*                                           # Strip whitespace before value.
      (?:                                           # Group for value alternatives.
        '(?<val>[^'\\]*(?:\\[\S\s][^'\\]*)*)'       # Either $1: Single quoted string,
      | ""(?<val>[^""\\]*(?:\\[\S\s][^""\\]*)*)""   # or $2: Double quoted string,
      | (?<val>[^,'""\s\\]*(?:\s+[^,'""\s\\]+)*)    # or $3: Non-comma, non-quote stuff.
      )                                             # End group of value alternatives.
      \s*                                           # Strip whitespace after value.
      (?:,|$)                                       # Field ends on comma or EOS.
      ";
 
  
 string[] values = (from Match m in Regex.Matches(line, pattern,
             RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline)
                            select m.Groups[1].Value).ToArray();
 
         return values;
     }
 
 }
DialogueBox Class
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class DialogueBox : MonoBehaviour
 {
 
     DialogeParser parser;
     public string dialogue;
     int lineNum;
     public GUIStyle customStyle;
     // Start is called before the first frame update
     void Start()
     {
         dialogue = "";
         parser = GameObject.Find("DialogueParserObject").GetComponent<DialogeParser>();
         lineNum = 0;
     }
 
     // Update is called once per frame
     void Update()
     {
         if (Input.GetMouseButtonDown(0))
         {
             dialogue = parser.GetContent(lineNum);
             lineNum++;
         }
     }
      void OnGUI()
     {
         dialogue = GUI.TextField(new Rect(100, 200, 600, 200),dialogue, customStyle);
     }
 
 }
 
 
       

Your answer
 
 
             Follow this Question
Related Questions
Help with options menu in unity 0 Answers
Visual studio errors... once again 0 Answers
Unity Shader Optimization? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                