public static UIPanelWrapper GenerateCustomizationPanel(this BuildingInfo building) { CustomizeIt.instance.CurrentBuilding = building; UIUtil.DestroyDeeply(UIView.Find("CustomizeItPanelWrapper")); UIPanelWrapper wrapper = UIView.GetAView().AddUIComponent(typeof(UIPanelWrapper)) as UIPanelWrapper; return(wrapper); }
private void AddBuildingPanelControls(WorldInfoPanel infoPanel, out UIButton button, Vector3 customizeButtonOffset) { button = UIUtil.CreateToggleButton(infoPanel.component, customizeButtonOffset, UIAlignAnchor.TopRight, delegate(UIComponent component, UIMouseEventParameter param) { InstanceID instanceID = (InstanceID)infoPanel.GetType().GetField("m_InstanceID", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(infoPanel); var building = BuildingManager.instance.m_buildings.m_buffer[instanceID.Building].Info; if (CustomizePanel == null || building != CurrentBuilding) { CustomizePanel = building.GenerateCustomizationPanel(); } else { CustomizePanel.isVisible = false; UIUtil.DestroyDeeply(CustomizePanel); } if (component.hasFocus) { component.Unfocus(); } }); }