// This gets called every time the translation needs updating public override void UpdateTranslation(LeanTranslation translation) { // Get the Text component attached to this GameObject var text = GetComponent<Text>(); // Use translation? if (translation != null) { text.text = translation.Text; } // Use fallback? else if (AllowFallback == true) { text.text = FallbackText; } }
// This gets called every time the translation needs updating public override void UpdateTranslation(LeanTranslation translation) { // Get the Text component attached to this GameObject var text = GetComponent <Text>(); // Use translation? if (translation != null) { text.text = translation.Text; } // Use fallback? else if (AllowFallback == true) { text.text = FallbackText; } }
// This gets called every time the translation needs updating public override void UpdateTranslation(LeanTranslation translation) { // Get the SpriteRenderer component attached to this GameObject var spriteRenderer = GetComponent<SpriteRenderer>(); // Use translation? if (translation != null) { spriteRenderer.sprite = translation.Object as Sprite; } // Use fallback? else if (AllowFallback == true) { spriteRenderer.sprite = FallbackSprite; } }
// This gets called every time the translation needs updating public override void UpdateTranslation(LeanTranslation translation) { // Get the Image component attached to this GameObject var image = GetComponent <Image>(); // Use translation? if (translation != null) { image.sprite = translation.Object as Sprite; } // Use fallback? else if (AllowFallback == true) { image.sprite = FallbackSprite; } }
// This gets called every time the translation needs updating public override void UpdateTranslation(LeanTranslation translation) { // Get the Image component attached to this GameObject var image = GetComponent<Image>(); // Use translation? if (translation != null) { image.sprite = translation.Object as Sprite; } // Use fallback? else if (AllowFallback == true) { image.sprite = FallbackSprite; } }
// Add a new translation to this phrase, or return the current one public LeanTranslation AddTranslation(string language) { var translation = FindTranslation(language); // Add it? if (translation == null) { translation = new LeanTranslation(); translation.Language = language; Translations.Add(translation); } return(translation); }
// This gets called every time the translation needs updating public override void UpdateTranslation(LeanTranslation translation) { // Get the AudioSource component attached to this GameObject var audioSource = GetComponent<AudioSource>(); // Use translation? if (translation != null) { audioSource.clip = translation.Object as AudioClip; } // Use fallback? else if (AllowFallback == true) { audioSource.clip = FallbackAudioClip; } }
// Add a new translation to this phrase, or return the current one public LeanTranslation AddTranslation(string language) { var translation = FindTranslation(language); // Add it? if (translation == null) { translation = new LeanTranslation(); translation.Language = language; Translations.Add(translation); } return translation; }
// This gets called every time the translation needs updating public override void UpdateTranslation(LeanTranslation translation) { // Get the AudioSource component attached to this GameObject var audioSource = GetComponent <AudioSource>(); // Use translation? if (translation != null) { audioSource.clip = translation.Object as AudioClip; } // Use fallback? else if (AllowFallback == true) { audioSource.clip = FallbackAudioClip; } }
// This gets called every time the translation needs updating public override void UpdateTranslation(LeanTranslation translation) { // Get the SpriteRenderer component attached to this GameObject var spriteRenderer = GetComponent <SpriteRenderer>(); // Use translation? if (translation != null) { spriteRenderer.sprite = translation.Object as Sprite; } // Use fallback? else if (AllowFallback == true) { spriteRenderer.sprite = FallbackSprite; } }
private void DrawTranslation(LeanTranslation translation) { BeginModifications(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Text", LabelStyle, GUILayout.Width(50.0f)); translation.Text = EditorGUILayout.TextArea(translation.Text); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Object", LabelStyle, GUILayout.Width(50.0f)); translation.Object = EditorGUILayout.ObjectField(translation.Object, typeof(Object), true); } EditorGUILayout.EndHorizontal(); } EndModifications(); }
private void DrawTranslations(LeanLocalization localization, LeanPhrase phrase) { existingLanguages.Clear(); for (var i = 0; i < phrase.Translations.Count; i++) { var labelA = Reserve(); var valueA = Reserve(ref labelA, 20.0f); var translation = phrase.Translations[i]; if (translationIndex == i) { BeginModifications(); { translation.Language = EditorGUI.TextField(labelA, "", translation.Language); } EndModifications(); if (GUI.Button(valueA, "X") == true) { MarkAsModified(); phrase.Translations.RemoveAt(i); translationIndex = -1; } } if (EditorGUI.Foldout(labelA, translationIndex == i, translationIndex == i ? "" : translation.Language) == true) { translationIndex = i; EditorGUI.indentLevel += 1; { DrawTranslation(translation); } EditorGUI.indentLevel -= 1; EditorGUILayout.Separator(); } else if (translationIndex == i) { translationIndex = -1; } if (existingLanguages.Contains(translation.Language) == true) { EditorGUILayout.HelpBox("This phrase has already been translated to this language!", MessageType.Warning); } else { existingLanguages.Add(translation.Language); } if (localization.Languages.Contains(translation.Language) == false) { EditorGUILayout.HelpBox("This translation uses a language that hasn't been set in the localization!", MessageType.Warning); } } for (var i = 0; i < localization.Languages.Count; i++) { var language = localization.Languages[i]; if (phrase.Translations.Exists(t => t.Language == language) == false) { var labelA = Reserve(); var valueA = Reserve(ref labelA, 120.0f); EditorGUI.LabelField(labelA, language); if (GUI.Button(valueA, "Create Translation") == true) { MarkAsModified(); var newTranslation = new LeanTranslation(); newTranslation.Language = language; newTranslation.Text = phrase.Name; translationIndex = phrase.Translations.Count; phrase.Translations.Add(newTranslation); } } } }
// This gets called every time the translation needs updating // NOTE: translation may be null if it can't be found public abstract void UpdateTranslation(LeanTranslation translation);
// Reverse lookup the phrases for this language private void DrawReverse(LeanLocalization localization, string language) { for (var i = 0; i < localization.Phrases.Count; i++) { var labelA = Reserve(); var phrase = localization.Phrases[i]; var translation = phrase.Translations.Find(t => t.Language == language); BeginModifications(); { EditorGUI.LabelField(labelA, phrase.Name); } EndModifications(); if (translation != null) { if (reverseIndex == i) { BeginModifications(); { phrase.Name = EditorGUI.TextField(labelA, "", phrase.Name); } EndModifications(); } if (EditorGUI.Foldout(labelA, reverseIndex == i, reverseIndex == i ? "" : phrase.Name) == true) { reverseIndex = i; EditorGUI.indentLevel += 1; { DrawTranslation(translation); } EditorGUI.indentLevel -= 1; EditorGUILayout.Separator(); } else if (reverseIndex == i) { reverseIndex = -1; } } else { var valueA = Reserve(ref labelA, 120.0f); if (GUI.Button(valueA, "Create Translation") == true) { MarkAsModified(); var newTranslation = new LeanTranslation(); newTranslation.Language = language; newTranslation.Text = phrase.Name; phrase.Translations.Add(newTranslation); } } } }