Hey everyone. I have an issue with my code. It’s a very strange issue since it always worked for me. I never changed anything in that code since everything worked.
The strange part is that the code itself seems to work fine until I do not change the language after i change the language let’s say from italian to english it’s immediately jump to the last translation and this issue never happened to me until today.
CODE:
```csharp
**using Cysharp.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.UI;
public class DialogueManager : MonoBehaviour
{
public TextMeshProUGUI nameText;
public TextMeshProUGUI dialogueText;
public Image images;
[SerializeField] private RectTransform ImageMove;
private const string KeyPlayerPrefs = "storyFinished";
public Dialogue dialogue;
private Queue<LocalizedString> sentences;
private Queue<Sprite> nextSprite;
private void OnEnable()
{
for (int i = 0; i < dialogue.sentences.Length; i++)
{
dialogue.sentences[i].StringChanged += updatevalueString;
}
dialogue.name.StringChanged += updateStringName;
}
private void OnDisable()
{
for (int i = 0; i < dialogue.sentences.Length; i++)
{
dialogue.sentences[i].StringChanged -= updatevalueString;
}
dialogue.name.StringChanged -= updateStringName;
}
private void updatevalueString(string value)
{
dialogueText.SetTextCysharp(value);
}
private void updateStringName(string value)
{
nameText.SetTextCysharp(value);
}
void Start()
{
if (!PlayerPrefs.HasKey(KeyPlayerPrefs))
{
PlayerPrefs.GetInt(KeyPlayerPrefs, 0);
}
else
{
if (PlayerPrefs.GetInt(KeyPlayerPrefs, 0) == 1)
{
PlayerPrefs.GetInt(KeyPlayerPrefs, 1);
LoadingScreenWaiter.instance.LoadScene(1);
}
}
LeanTween.moveLocalX(ImageMove.gameObject, -93.956f, 0.75f).setEaseLinear();
sentences = new Queue<LocalizedString>();
nextSprite = new Queue<Sprite>();
StartDialogue(dialogue);
}
public void StartDialogue(Dialogue dialogue)
{
nameText.text = dialogue.name.GetLocalizedString();
sentences.Clear();
nextSprite.Clear();
foreach (LocalizedString strings in dialogue.sentences)
{
sentences.Enqueue(strings);
}
foreach (Sprite image in dialogue.nextImage)
{
nextSprite.Enqueue(image);
}
DisplayNextSentence();
}
public void DisplayNextSentence()
{
if (sentences.Count == 0)
{
EndDialogue();
return;
}
string sentence = sentences.Dequeue().GetLocalizedString();
Sprite image = null;
if (nextSprite.Count > -1)
{
image = nextSprite.Dequeue();
images.sprite = image;
}
StopAllCoroutines();
StartCoroutine(TypeSentence(sentence));
}
IEnumerator TypeSentence(string sentence)
{
dialogueText.text = "";
foreach (char letter in sentence.ToCharArray())
{
dialogueText.text += letter;
yield return null;
}
}
void EndDialogue()
{
PlayerPrefs.SetInt(KeyPlayerPrefs, 1);
LoadingScreenWaiter.instance.LoadScene(1);
}
public void TriggerDialogue()
{
StartDialogue(dialogue);
}
}**
```