using System; using UnityEngine; public class StringOption : OptionBehaviour { public TextRenderer TitleText; public TextRenderer ValueText; public string[] Values; public int Value; private int oldValue = -1; public void OnEnable() { this.TitleText.Text = DestroyableSingleton.Instance.GetString(this.Title, Array.Empty()); this.ValueText.Text = this.Values[this.Value]; GameOptionsData gameOptions = PlayerControl.GameOptions; StringNames title = this.Title; if (title == StringNames.GameMapName) { this.Value = (int)gameOptions.MapId; return; } if (title == StringNames.GameKillDistance) { this.Value = gameOptions.KillDistance; return; } Debug.Log("Ono, unrecognized setting: " + this.Title); } private void FixedUpdate() { if (this.oldValue != this.Value) { this.oldValue = this.Value; this.ValueText.Text = this.Values[this.Value]; } } public void Increase() { this.Value = Mathf.Clamp(this.Value + 1, 0, this.Values.Length - 1); this.OnValueChanged(this); } public void Decrease() { this.Value = Mathf.Clamp(this.Value - 1, 0, this.Values.Length - 1); this.OnValueChanged(this); } public override int GetInt() { return this.Value; } }