Beispiel #1
0
 public void LoadScript(Program program, IDictionary <string, Yarn.Compiler.StringInfo> stringInfo)
 {
     if (scriptToLoad != null)
     {
         DialogueRunner dialogueRunner = FindObjectOfType <Yarn.Unity.DialogueRunner>();
         dialogueRunner.AddStringTable(stringInfo);
         dialogueRunner.Dialogue.AddProgram(program);
     }
 }
    // Method is to be used with GameManager.cs in order to load files for the DialogueRunner
    public void LoadFileToRun()
    {
        string txtDocumentName = Application.streamingAssetsPath + "/Char_Dialogues/" + file.Name;

        Debug.Log("Loading " + file.Name + " in " + txtDocumentName);
        Yarn.Program script;
        IDictionary <string, StringInfo> dialogueStrings;

        // This method returns the Program, which contains nodes and returns the strings
        Yarn.Compiler.Compiler.CompileFile(txtDocumentName, out script, out dialogueStrings);

        #region prints for Program and StringInfo
        // Debug.Log(a.Count);
        // print("StringInfo");
        // foreach(string k in a.Keys){
        //     print(k);
        // }
        // foreach(StringInfo k in a.Values){
        //     print(k.text);
        // }

        // print("Program");
        // print(script);
        // print(script.Nodes.Count);
        // foreach(string k in script.Nodes.Keys){
        //     print(k);
        // }
        // foreach(Yarn.Node k in script.Nodes.Values){
        //     print(k);
        // }
        #endregion

        if (dialogueStrings != null && script != null)
        {
            DialogueRunner dialogueRunner = FindObjectOfType <Yarn.Unity.DialogueRunner>();
            dialogueRunner.AddStringTable(dialogueStrings);
            dialogueRunner.Dialogue.AddProgram(script);
            // print(dialogueRunner.CurrentNodeName);
            // print(dialogueRunner.startNode);
            // print(dialogueRunner.NodeExists("Shina"));
        }

        // Somehow a null reference when sending in the strings through the method.
        // npc.LoadScript2(a);
    }