public override void OnLevelUnloading() { ServiceBuildingOptions.GetInstance().Clear(); DistrictSelectionPanel.Uninstall(); harmonyInstance.UnpatchAll(harmonyId); harmonyInstance = null; }
public static void Uninstall() { if (Root != null) { UIPanel servicePanel = GetPanel(SERVICE_PANEL_NAME); servicePanel.eventVisibilityChanged -= Panel.OnVisibilityChanged; servicePanel.eventPositionChanged -= Panel.OnPositionChanged; GameObject.Destroy(Root); Panel = null; Root = null; } }
private void ActivateMod() { Utils.LogGeneral("[Loading mod]"); Stopwatch sw = new Stopwatch(); sw.Start(); harmonyInstance = HarmonyInstance.Create(harmonyId); harmonyInstance.PatchAll(Assembly.GetExecutingAssembly()); Utils.LogGeneral("District Service Limit installing panel..."); DistrictSelectionPanel.Install(); sw.Stop(); Utils.LogGeneral("District Service Limit mod loaded in " + sw.ElapsedMilliseconds + "ms"); Utils.LogGeneral("[/Loading mod]\n"); }
public static void Install() { Root = new GameObject("DistrictSelectionPanelGO"); Panel = Root.AddComponent <DistrictSelectionPanel>(); Utils.LogGeneral("[District Service Limit] " + "Root=" + Root + ", Panel=" + Panel); //UIPanel servicePanel = UIView.Find<UIPanel>("(Library) CityServiceWorldInfoPanel"); servicePanel = GetPanel(SERVICE_PANEL_NAME); if (servicePanel == null) { throw new Exception("UIPanel not found (update broke the mod!): " + SERVICE_PANEL_NAME + ". \nAvailable panels are:\n" + string.Join(" \n", GetUIPanelNames())); } Utils.LogGeneral("[District Service Limit] " + "servicePanel=" + servicePanel + ", transform=" + servicePanel.transform); Panel.basePanel = servicePanel.gameObject.GetComponent <CityServiceWorldInfoPanel>(); Panel.transform.parent = servicePanel.transform; Utils.LogGeneral("[District Service Limit] " + "basePanel=" + Panel.basePanel); servicePanel.eventVisibilityChanged += Panel.OnVisibilityChanged; servicePanel.eventPositionChanged += Panel.OnPositionChanged; AdjustPosition(); }