using System; using SRDebugger.UI.Other; using SRF; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; namespace SRDebugger.UI { public class MobileMenuController : SRMonoBehaviourEx { public float PeekAmount { get { return this._peekAmount; } } public float MaxMenuWidth { get { return this._maxMenuWidth; } } protected override void OnEnable() { base.OnEnable(); RectTransform rectTransform = this.Menu.parent as RectTransform; LayoutElement component = this.Menu.GetComponent(); component.ignoreLayout = true; this.Menu.pivot = new Vector2(1f, 1f); this.Menu.offsetMin = new Vector2(1f, 0f); this.Menu.offsetMax = new Vector2(1f, 1f); this.Menu.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Clamp(rectTransform.rect.width - this.PeekAmount, 0f, this.MaxMenuWidth)); this.Menu.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, rectTransform.rect.height); this.Menu.anchoredPosition = new Vector2(0f, 0f); if (this._closeButton == null) { this.CreateCloseButton(); } this.OpenButton.gameObject.SetActive(true); this.TabController.ActiveTabChanged += this.TabControllerOnActiveTabChanged; } protected override void OnDisable() { base.OnDisable(); LayoutElement component = this.Menu.GetComponent(); component.ignoreLayout = false; this.Content.anchoredPosition = new Vector2(0f, 0f); this._closeButton.gameObject.SetActive(false); this.OpenButton.gameObject.SetActive(false); this.TabController.ActiveTabChanged -= this.TabControllerOnActiveTabChanged; } private void CreateCloseButton() { GameObject gameObject = new GameObject("SR_CloseButtonCanvas", new Type[] { typeof(RectTransform) }); gameObject.transform.SetParent(this.Content, false); Canvas canvas = gameObject.AddComponent(); gameObject.AddComponent(); RectTransform componentOrAdd = gameObject.GetComponentOrAdd(); canvas.overrideSorting = true; canvas.sortingOrder = 122; gameObject.AddComponent().ignoreLayout = true; this.SetRectSize(componentOrAdd); GameObject gameObject2 = new GameObject("SR_CloseButton", new Type[] { typeof(RectTransform) }); gameObject2.transform.SetParent(componentOrAdd, false); RectTransform component = gameObject2.GetComponent(); this.SetRectSize(component); gameObject2.AddComponent().color = new Color(0f, 0f, 0f, 0f); this._closeButton = gameObject2.AddComponent