private void Start() { _play = _buttonList.Add("Play") as UIMenuButton; _quit = _buttonList.Add("Quit") as UIMenuButton; _play.Pressed += Play_Pressed; _quit.Pressed += Quit_Pressed; }
//////////////// private ModRecommendsMenuContext() : base(true, false) { this.RecommendsList = new UIRecommendsList(this, 198f, 132f, 202f, 40f); this.DownloadButton = new UIMenuButton(UITheme.Vanilla, "Download All", 198f, 26f, 202f, 172f); this.DownloadButton.OnClick += (evt, elem) => { MainMenuHelpers.LoadMenuModDownloads("Recommended", (List <string>) this.RecommendsList.GetModNames()); }; }
private void Button_Pressed(UIMenuButton button) { if (ButtonPressed != null) { ButtonPressed(_buttons[button]); } _current = button; }
public void Select(MenuBase menu) { if (_buttons.ContainsValue(menu)) { if (_current != null) { _current.Selected(false); } _current = _buttons.FirstOrDefault(x => x.Value == menu).Key; _current.Selected(true); } }
public void AddButton(MenuBase menu, string label) { var instance = UIUtility.Add <UIMenuButton>(transform, Prototype.gameObject); instance.Label = label; instance.Pressed += Button_Pressed; if (_current == null) { _current = instance; } _buttons.Add(instance, menu); }
private void MakeBrushMenuTab() { UIMenuButton[] allTheButtons = FindObjectsOfType <UIMenuButton>(); UIMenuButton button = allTheButtons.FirstOrDefault(btn => btn.name.StartsWith("DecoBuilder")); if (button == null) { _handleButtonCreateError(); return; } UIWindow decoWindow = Instantiate(button.windowContentGO); DecoBuilderTab tab = decoWindow.gameObject.GetComponentInChildren <DecoBuilderTab>(); //copy GameObject tbUIMenuButton = Instantiate(button.gameObject); tbUIMenuButton.transform.SetParent(button.transform.parent, false); tbBuilderButton = tbUIMenuButton.GetComponent <UIMenuButton>(); //reposition RectTransform cloneTfm = tbUIMenuButton.GetComponent <RectTransform>(); Vector2 anchorMin = cloneTfm.anchorMin; Vector2 anchorMax = cloneTfm.anchorMax; anchorMin.x = 0.3515f; anchorMax.x = 0.3615f; cloneTfm.anchorMin = anchorMin; cloneTfm.anchorMax = anchorMax; tbUIMenuButton.name = "TreeBrush"; //tooltip UITooltip tooltip = tbUIMenuButton.GetComponent <UITooltip>(); tooltip.text = "Tree Brush"; // This steals the materials from the Deco Builder so we can use them ourselves on our own objects if (tab != null) { Builder builder = Instantiate(tab.builderGO); //ghostMat = builder.ghostMaterial; //ghostIntersectMat = builder.ghostIntersectMaterial; //ghostCantBuildMat = builder.ghostCantBuildMaterial; Destroy(builder.gameObject); } Destroy(decoWindow.gameObject); }
private void GenerateMenuButton(UIPage page) { var menuButton = Instantiate(TemplateMenuButton); menuButton.interactable = !page.IsCurrentPage(); //menuButton.transform.SetParent(this.transform); menuButton.transform.SetParent(Container.transform); menuButton.name = string.Format("{0} Menu Button", page.name); //GameObjectHelpers.NormalizeTransform(menuButton.transform); menuButton.transform.ResetScaleAndRotation(); menuButton.GetComponentInChildren <Text>().text = page.GetHeader(); menuButton.onClick.AddListener(delegate { page.NavigateTo(); }); page.OnNavigatedTo.AddListener(onNavigatedTo); var uiMenuButton = new UIMenuButton { MenuButton = menuButton, Page = page }; MenuButtons.Add(uiMenuButton); }
private void UIRootView_MouseLeave(object sender, MouseEventArgs e) { UIMenuButton.Animation_Opacity_View_Frame(false, () => { UIMenuButton.Visibility = System.Windows.Visibility.Collapsed; }); }
private void UIRootView_MouseEnter(object sender, MouseEventArgs e) { UIMenuButton.Visibility = System.Windows.Visibility.Visible; UIMenuButton.Animation_Opacity_View_Frame(true); }