Announcements, support questions, and discussion for the Dialogue System.
Thistis
Posts: 27 Joined: Sat Oct 05, 2019 5:05 pm
Post
by Thistis » Tue Oct 15, 2019 5:40 pm
Hello,
one question about TextTable. How do I get an instance of a TextTable via Code?
In the documentation, it says:
Code: Select all
var hello = myTextTable.GetFieldTextForLanguage("Hello", "FR");
But how do I get the myTextTable? Is there a method to search a TextTable by name?
I couldn't find something fitting in the TextTable class documentation.
All the best,
Evelyn
Tony Li
Posts: 22055 Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li » Tue Oct 15, 2019 7:29 pm
Hi Evelyn,
A good way is to add a variable to your script that you can assign in the Inspector:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class TestClass : MonoBehaviour
{
public TextTable myTextTable; // <-- ASSIGN IN INSPECTOR.
private void Start()
{
Debug.Log("Text Table " + myTextTable.name + " has " + myTextTable.GetFieldNames().Length + " fields.");
}
}
Alternatively, you can put the TextTable in a
Resources folder and use Resources.Load to load it at runtime:
Code: Select all
TextTable myTextTable = Resources.Load<TextTable>("Your TextTable Asset Name");