using System; using System.Collections.Generic; using UnityEngine; namespace I2.Loc { public class LocalizationParamsManager : MonoBehaviour, ILocalizationParamsManager { public string GetParameterValue(string ParamName) { if (this._Params != null) { int i = 0; int count = this._Params.Count; while (i < count) { if (this._Params[i].Name == ParamName) { return this._Params[i].Value; } i++; } } return null; } public void SetParameterValue(string ParamName, string ParamValue, bool localize = true) { bool flag = false; int i = 0; int count = this._Params.Count; while (i < count) { if (this._Params[i].Name == ParamName) { LocalizationParamsManager.ParamValue value = this._Params[i]; value.Value = ParamValue; this._Params[i] = value; flag = true; break; } i++; } if (!flag) { this._Params.Add(new LocalizationParamsManager.ParamValue { Name = ParamName, Value = ParamValue }); } if (localize) { this.OnLocalize(); } } public void OnLocalize() { Localize component = base.GetComponent(); if (component != null) { component.OnLocalize(true); } } public virtual void OnEnable() { this.DoAutoRegister(); } public void DoAutoRegister() { if (!LocalizationManager.ParamManagers.Contains(this)) { LocalizationManager.ParamManagers.Add(this); LocalizationManager.LocalizeAll(true); } } public void OnDisable() { LocalizationManager.ParamManagers.Remove(this); } [SerializeField] public List _Params = new List(); [Serializable] public struct ParamValue { public string Name; public string Value; } } }