// // /*=============================================================================== // // Copyright (C) 2024 PhantomsXR Ltd. All Rights Reserved. // // // // This file is part of the Assembly-CSharp. // // // // The Localization cannot be copied, distributed, or made available to // // third-parties for commercial purposes without written permission of PhantomsXR Ltd. // // // // Contact info@phantomsxr.com for licensing requests. // // ===============================================================================*/ using System; using Phantom.XRMOD.Localization.Runtime; using TMPro; using UnityEngine; namespace DefaultNamespace { public class DynamicStringLocalizedTest : MonoBehaviour { private TextMeshProUGUI textMeshProUGUI; private int count = 1; private void Awake() { LocalizationManager.Instance.Initialized(Resources.Load("Localization").bytes, Application.systemLanguage.ToString()); } private void Start() { textMeshProUGUI = GetComponent(); textMeshProUGUI.text = "ExamplesTitle".Localized(); InvokeRepeating(nameof(UpdateTime), 2, 1); } [ContextMenu("ChangeLanguage")] public void ChangeLanguage() { var tmp_Language = Resources.Load("Localization").bytes; LocalizationManager.Instance.ChangeLanguage(tmp_Language, SystemLanguage.English.ToString()); } [ContextMenu("Create A new Dynamic Text")] private void CreateDynamicText() { GameObject tmp_GameObject = new GameObject("DynamicCreatedText"); tmp_GameObject.transform.SetParent(GameObject.Find("Canvas").transform); tmp_GameObject.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); var tmp_TextMeshProGui = tmp_GameObject.AddComponent(); tmp_TextMeshProGui.SetKey("ExamplesTitle"); } void UpdateTime() { count++; textMeshProUGUI.text = $"{"Countdown".Localized()}{count}{"Seconds".Localized()}"; } } }