protected Button.ButtonClickedEvent SetupPopupMenu(ButtonInfo binfo, KButton button) { Button.ButtonClickedEvent buttonClickedEvent = new Button.ButtonClickedEvent(); UnityAction unityAction = delegate { List <ButtonInfo> list = new List <ButtonInfo>(); if (binfo.onPopulatePopup != null) { binfo.popupOptions = binfo.onPopulatePopup(); } string[] popupOptions = binfo.popupOptions; foreach (string text in popupOptions) { string delegate_str = text; list.Add(new ButtonInfo(delegate_str, delegate { binfo.onPopupClick(delegate_str); if (!keepMenuOpen) { Deactivate(); } }, Action.NumActions, null, null, null, true, null, null, null)); } KButtonMenu component = Util.KInstantiate(ScreenPrefabs.Instance.ButtonGrid.gameObject, null, null).GetComponent <KButtonMenu>(); component.SetButtons(list.ToArray()); RootMenu.Instance.AddSubMenu(component); Game.Instance.LocalPlayer.ScreenManager.ActivateScreen(component.gameObject, null, GameScreenManager.UIRenderTarget.ScreenSpaceOverlay); Vector3 b = default(Vector3); if (Util.IsOnLeftSideOfScreen(button.transform.GetPosition())) { b.x = button.GetComponent <RectTransform>().rect.width * 0.25f; } else { b.x = (0f - button.GetComponent <RectTransform>().rect.width) * 0.25f; } component.transform.SetPosition(button.transform.GetPosition() + b); }; binfo.onClick = unityAction; buttonClickedEvent.AddListener(unityAction); return(buttonClickedEvent); }