I’ve got static localization down, but I’m having trouble with dynamic localization.
I have a "Victory"
scene in which I need to indicate which player has won. I have a PlayerPrefs
setting that contains the number of the player. My String table contains entries like
Key,en,fil,...
playerwins,"Player {0} Wins", "Nanalo ang Manlalarov {0}",etc.
I have attached my VictoryController.cs
script to a text object that is set up with the dynamic key
public class VictoryController : MonoBehaviour
{
public AudioSource applause1;
public AudioSource applause2;
public AudioSource applause3;
private bool soundOn = true;
private List<AudioSource> applauseSounds;
public LocalizedString localStringVictor;
public TMP_Text textComp;
private string victor;
public void Awake()
{
victor = PlayerPrefs.GetString("Victor");
localStringVictor.Arguments[0] = victor;
localStringVictor.RefreshString();
...
I have set the public variable localStringVictor
to the correct entry in my string table. I set the textComp
variable to the TMP_TXT
in the string object.
I get a null reference exception the first time I reference the localStringVictor
variable in my script.
What am I doing wrong?