mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Merge branch 'dev' into documentation-improvement
This commit is contained in:
commit
791daa08ad
19 files changed
+220
-48
No files matched your search
@@ -96,7 +96,7 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
|
||||
onClick(null);
|
||||
}));
|
||||
|
||||
DestroyableSingleton<DebugAnalytics>.Instance.Analytics.MinigameOpened(PlayerControl.LocalPlayer.Data, TaskType);
|
||||
DebugAnalytics.Instance.Analytics.MinigameOpened(PlayerControl.LocalPlayer.Data, TaskType);
|
||||
var list = PlayerControl.AllPlayerControls.ToArray().Where(playerMatch).ToList();
|
||||
potentialVictims = [];
|
||||
var list2 = new Il2CppSystem.Collections.Generic.List<UiElement>();
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -137,7 +138,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
internal void DestroyComponent(ModifierUiComponent component)
|
||||
{
|
||||
_modifiers.Remove(component.Modifier!);
|
||||
component.gameObject.DestroyImmediate();
|
||||
component.gameObject.DeepDestroy();
|
||||
RefreshModifiers();
|
||||
}
|
||||
|
||||
@@ -207,7 +208,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
continue;
|
||||
}
|
||||
|
||||
mod.Value.gameObject.Destroy();
|
||||
mod.Value.gameObject.DeepDestroy();
|
||||
_modifiers.Remove(mod.Key);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public static class DetectiveNotesMinigamePatch
|
||||
return;
|
||||
}
|
||||
__instance.impostorButton = new List<GameObject>();
|
||||
var allRoles = DestroyableSingleton<RoleManager>.Instance.AllRoles;
|
||||
var allRoles = RoleManager.Instance.AllRoles;
|
||||
var customRoles = CustomRoleManager.CustomRoleBehaviours;
|
||||
foreach (var role in allRoles)
|
||||
{
|
||||
|
||||
@@ -276,8 +276,9 @@ public static class TaskAdderPatches
|
||||
__instance.transform.FindChild("TitleText_TMP")?.gameObject.DestroyImmediate();
|
||||
}
|
||||
|
||||
__instance.ActiveItems.ToArray().Do(x => x.gameObject.Destroy());
|
||||
__instance.ActiveItems.ToArray().Do(x => x.gameObject.DeepDestroy(false));
|
||||
__instance.ActiveItems.Clear();
|
||||
Utilities.Extensions.ClearGarbageCollector();
|
||||
|
||||
float num = 0f;
|
||||
float num2 = 0f;
|
||||
|
||||
@@ -143,8 +143,9 @@ public static class HudManagerPatches
|
||||
|
||||
foreach (var t in BottomLeft.GetComponentsInChildren<ActionButton>(true))
|
||||
{
|
||||
t.gameObject.Destroy();
|
||||
t.gameObject.DeepDestroy(false);
|
||||
}
|
||||
Utilities.Extensions.ClearGarbageCollector();
|
||||
|
||||
var gridArrange = BottomLeft.GetComponent<GridArrange>();
|
||||
var aspectPosition = BottomLeft.GetComponent<AspectPosition>();
|
||||
|
||||
@@ -21,8 +21,8 @@ public static class ToggleBehaviourPatch
|
||||
// Used to mask the text
|
||||
__instance.Text.richText = true;
|
||||
__instance.Text.text = $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">" +
|
||||
$"{DestroyableSingleton<TranslationController>.Instance.GetString(__instance.BaseText)}: <b>" +
|
||||
$"{DestroyableSingleton<TranslationController>.Instance.GetString(__instance.onState ? StringNames.SettingsOn : StringNames.SettingsOff)}</b></font>";
|
||||
$"{TranslationController.Instance.GetString(__instance.BaseText)}: <b>" +
|
||||
$"{TranslationController.Instance.GetString(__instance.onState ? StringNames.SettingsOn : StringNames.SettingsOff)}</b></font>";
|
||||
__instance.Text.sortingOrder = 151;
|
||||
__instance.Text.renderer.sortingLayerName = "Default";
|
||||
__instance.Text.renderer.sortingOrder = 151;
|
||||
|
||||
@@ -11,8 +11,6 @@ using Reactor.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace MiraAPI.Patches.Menu;
|
||||
@@ -94,9 +92,10 @@ public static class HatsTabPatches
|
||||
if (loadRoutine != null) Coroutines.Stop(loadRoutine);
|
||||
|
||||
hatIndex = 0;
|
||||
foreach (var instanceColorChip in __instance.ColorChips) instanceColorChip.gameObject.Destroy();
|
||||
foreach (var instanceColorChip in __instance.ColorChips) instanceColorChip.gameObject.DeepDestroy(false);
|
||||
__instance.ColorChips.Clear();
|
||||
__instance.scroller.Inner.GetComponentsInChildren<TextMeshPro>().Do(x => x.gameObject.Destroy());
|
||||
__instance.scroller.Inner.GetComponentsInChildren<TextMeshPro>().Do(x => x.gameObject.DeepDestroy(false));
|
||||
Utilities.Extensions.ClearGarbageCollector();
|
||||
|
||||
var groupNameText = __instance.GetComponentInChildren<TextMeshPro>(false);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
@@ -13,6 +14,8 @@ namespace MiraAPI.Patches.Menu;
|
||||
[HarmonyPatch(typeof(MainMenuManager))]
|
||||
public static class MainMenuManagerPatches
|
||||
{
|
||||
internal static bool NeedsDeepDestroy { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A postifix on Awake to load all the addressables registered.
|
||||
/// </summary>
|
||||
@@ -20,6 +23,9 @@ public static class MainMenuManagerPatches
|
||||
[HarmonyPostfix]
|
||||
public static void AwakePostfix()
|
||||
{
|
||||
var requiredVersion = new Version(2026, 6, 5);
|
||||
var version = Version.Parse(Application.version);
|
||||
NeedsDeepDestroy = version >= requiredVersion;
|
||||
AddressablesLoader.LoadAll();
|
||||
Coroutines.Start(SetFps());
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public static class NameplatesTabPatches
|
||||
}
|
||||
__instance.plateId = HatManager.Instance.GetNamePlateById(DataManager.Player.Customization.namePlate).ProdId;
|
||||
|
||||
if (!SortedNameplates.ContainsKey("Vanilla")) AddRange(DestroyableSingleton<HatManager>.Instance.GetUnlockedNamePlates().Select(x => ("Vanilla", x)));
|
||||
if (!SortedNameplates.ContainsKey("Vanilla")) AddRange(HatManager.Instance.GetUnlockedNamePlates().Select(x => ("Vanilla", x)));
|
||||
|
||||
InventoryUtility.CreateNextBackButtons(__instance, PreviousPage, NextPage);
|
||||
|
||||
@@ -81,9 +81,10 @@ public static class NameplatesTabPatches
|
||||
|
||||
private static void GenerateHats(NameplatesTab __instance, int page)
|
||||
{
|
||||
foreach (ColorChip instanceColorChip in __instance.ColorChips) instanceColorChip.gameObject.Destroy();
|
||||
foreach (var instanceColorChip in __instance.ColorChips) instanceColorChip.gameObject.DeepDestroy(false);
|
||||
__instance.ColorChips.Clear();
|
||||
__instance.scroller.Inner.GetComponentsInChildren<TextMeshPro>().Do(x => x.gameObject.Destroy());
|
||||
__instance.scroller.Inner.GetComponentsInChildren<TextMeshPro>().Do(x => x.gameObject.DeepDestroy(false));
|
||||
Utilities.Extensions.ClearGarbageCollector();
|
||||
|
||||
var groupNameText = __instance.GetComponentInChildren<TextMeshPro>(false);
|
||||
|
||||
|
||||
@@ -83,9 +83,10 @@ public static class SkinsTabPatches
|
||||
|
||||
private static void GenerateHats(SkinsTab __instance, int page)
|
||||
{
|
||||
foreach (ColorChip instanceColorChip in __instance.ColorChips) instanceColorChip.gameObject.Destroy();
|
||||
foreach (var instanceColorChip in __instance.ColorChips) instanceColorChip.gameObject.DeepDestroy(false);
|
||||
__instance.ColorChips.Clear();
|
||||
__instance.scroller.Inner.GetComponentsInChildren<TextMeshPro>().Do(x => x.gameObject.Destroy());
|
||||
__instance.scroller.Inner.GetComponentsInChildren<TextMeshPro>().Do(x => x.gameObject.DeepDestroy(false));
|
||||
Utilities.Extensions.ClearGarbageCollector();
|
||||
|
||||
var groupNameText = __instance.GetComponentInChildren<TextMeshPro>(false);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public static class VisorsTabPatches
|
||||
}
|
||||
__instance.visorId = HatManager.Instance.GetVisorById(DataManager.Player.Customization.Visor).ProdId;
|
||||
|
||||
if (!SortedVisors.ContainsKey("Vanilla")) AddRange(DestroyableSingleton<HatManager>.Instance.GetUnlockedVisors().Select(x => ("Vanilla", x)));
|
||||
if (!SortedVisors.ContainsKey("Vanilla")) AddRange(HatManager.Instance.GetUnlockedVisors().Select(x => ("Vanilla", x)));
|
||||
|
||||
InventoryUtility.CreateNextBackButtons(__instance, PreviousPage, NextPage);
|
||||
|
||||
@@ -81,9 +81,10 @@ public static class VisorsTabPatches
|
||||
|
||||
private static void GenerateHats(VisorsTab __instance, int page)
|
||||
{
|
||||
foreach (ColorChip instanceColorChip in __instance.ColorChips) instanceColorChip.gameObject.Destroy();
|
||||
foreach (var instanceColorChip in __instance.ColorChips) instanceColorChip.gameObject.DeepDestroy(false);
|
||||
__instance.ColorChips.Clear();
|
||||
__instance.scroller.Inner.GetComponentsInChildren<TextMeshPro>().Do(x => x.gameObject.Destroy());
|
||||
__instance.scroller.Inner.GetComponentsInChildren<TextMeshPro>().Do(x => x.gameObject.DeepDestroy(false));
|
||||
Utilities.Extensions.ClearGarbageCollector();
|
||||
|
||||
var groupNameText = __instance.GetComponentInChildren<TextMeshPro>(false);
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ internal static class GamePresetsTabPatches
|
||||
iconSpriteRend.sprite = MiraAssets.RefreshIcon.LoadAsset();
|
||||
|
||||
Helpers.DivideSize(refreshButton.gameObject, 2f);
|
||||
refreshButton.buttonText.gameObject.Destroy();
|
||||
refreshButton.buttonText.gameObject.DeepDestroy();
|
||||
|
||||
refreshButton.OnClick = new Button.ButtonClickedEvent();
|
||||
refreshButton.OnClick.AddListener((UnityAction)Refresh);
|
||||
|
||||
@@ -53,15 +53,30 @@ public static class RoleSettingMenuPatches
|
||||
[HarmonyPatch(nameof(RolesSettingsMenu.SetQuotaTab))]
|
||||
public static bool SetQuotaTabPatch(RolesSettingsMenu __instance)
|
||||
{
|
||||
Headers.ForEach(Object.Destroy);
|
||||
RoleOptionSettings.ForEach(Object.Destroy);
|
||||
foreach (var obj in Headers)
|
||||
{
|
||||
if (!obj)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
obj.DeepDestroy(false);
|
||||
}
|
||||
Headers.Clear();
|
||||
foreach (var obj in RoleOptionSettings)
|
||||
{
|
||||
if (!obj)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
obj.gameObject.DeepDestroy(false);
|
||||
}
|
||||
RoleOptionSettings.Clear();
|
||||
CurrentRole = null;
|
||||
CurrentRoleOptions = null;
|
||||
|
||||
__instance.roleChances = new Il2CppSystem.Collections.Generic.List<RoleOptionSetting>();
|
||||
__instance.advancedSettingChildren = new Il2CppSystem.Collections.Generic.List<OptionBehaviour>();
|
||||
Utilities.Extensions.ClearGarbageCollector();
|
||||
|
||||
var maskBg = __instance.scrollBar.transform.FindChild("MaskBg");
|
||||
var hitbox = __instance.scrollBar.transform.FindChild("Hitbox");
|
||||
@@ -204,9 +219,9 @@ public static class RoleSettingMenuPatches
|
||||
var blankLabel = quotaInst.transform.FindChild("BlankLabel").gameObject;
|
||||
var chanceLabel = quotaInst.transform.FindChild("Chance Label").gameObject;
|
||||
var countLabel = quotaInst.transform.FindChild("# Label").gameObject;
|
||||
blankLabel.Destroy();
|
||||
chanceLabel.Destroy();
|
||||
countLabel.Destroy();
|
||||
blankLabel.DeepDestroy(false);
|
||||
chanceLabel.DeepDestroy(false);
|
||||
countLabel.DeepDestroy(false);
|
||||
|
||||
categoryHeaderMasked.Background.sprite = MiraAssets.CategoryHeader.LoadAsset();
|
||||
categoryHeaderMasked.Background.sprite.texture.filterMode = FilterMode.Bilinear;
|
||||
@@ -289,16 +304,25 @@ public static class RoleSettingMenuPatches
|
||||
{
|
||||
RoleGroupHidden[group] = !groupHidden;
|
||||
}
|
||||
foreach (var header in Headers)
|
||||
foreach (var obj in Headers)
|
||||
{
|
||||
header.Destroy();
|
||||
if (!obj)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
obj.DeepDestroy(false);
|
||||
}
|
||||
Headers.Clear();
|
||||
foreach (var option in RoleOptionSettings)
|
||||
foreach (var obj in RoleOptionSettings)
|
||||
{
|
||||
option.gameObject.Destroy();
|
||||
if (!obj)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
obj.gameObject.DeepDestroy(false);
|
||||
}
|
||||
RoleOptionSettings.Clear();
|
||||
Utilities.Extensions.ClearGarbageCollector();
|
||||
__instance.SetQuotaTab();
|
||||
}));
|
||||
headerBtn.SetButtonEnableState(true);
|
||||
@@ -422,11 +446,12 @@ public static class RoleSettingMenuPatches
|
||||
{
|
||||
foreach (var optBehaviour in __instance.AdvancedRolesSettings.GetComponentsInChildren<OptionBehaviour>())
|
||||
{
|
||||
optBehaviour.gameObject.DestroyImmediate();
|
||||
optBehaviour.gameObject.DeepDestroy(false);
|
||||
}
|
||||
|
||||
CurrentRole = role;
|
||||
__instance.advancedSettingChildren.Clear();
|
||||
Utilities.Extensions.ClearGarbageCollector();
|
||||
|
||||
// TODO: create sub groups under the role settings.
|
||||
var filteredOptions = GameSettingMenuPatches.SelectedMod?.InternalOptionGroups
|
||||
@@ -618,7 +643,7 @@ public static class RoleSettingMenuPatches
|
||||
var newButton = Object.Instantiate(roleOptionSetting.buttons[0], roleOptionSetting.transform);
|
||||
newButton.name = "ConfigButton";
|
||||
newButton.transform.localPosition = new Vector3(0.4473f, -0.3f, -2f);
|
||||
newButton.transform.FindChild("Text_TMP").gameObject.DestroyImmediate();
|
||||
newButton.transform.FindChild("Text_TMP").gameObject.DeepDestroy();
|
||||
newButton.activeSprites.Destroy();
|
||||
|
||||
var btnRend = newButton.transform.FindChild("ButtonSprite").GetComponent<SpriteRenderer>();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using HarmonyLib;
|
||||
using InnerNet;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Patches.Roles;
|
||||
|
||||
@@ -69,9 +71,10 @@ public static class HudManagerPatches
|
||||
|
||||
CustomRoleManager.UpdateRoleTab(RoleTab, customRole);
|
||||
}
|
||||
else if (RoleTab)
|
||||
else if (RoleTab != null)
|
||||
{
|
||||
RoleTab?.gameObject.Destroy();
|
||||
RoleTab.gameObject.DeepDestroy();
|
||||
RoleTab = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -61,7 +62,7 @@ public static class PresetManager
|
||||
{
|
||||
if (btn != null)
|
||||
{
|
||||
Object.DestroyImmediate(btn);
|
||||
btn.DeepDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SavePresetPopup(nint cppPtr) : Minigame(cppPtr)
|
||||
// Cleanup holder object
|
||||
public void OnDestroy()
|
||||
{
|
||||
transform.parent.gameObject.Destroy();
|
||||
transform.parent.gameObject.DeepDestroy();
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
|
||||
@@ -171,24 +171,24 @@ public static class AddressablesLoader
|
||||
var visorBehaviours = DiscoverAndReportData<VisorData>(RegisteredVisorKeys);
|
||||
|
||||
var hatData = new List<HatData>();
|
||||
hatData.AddRange(DestroyableSingleton<HatManager>.Instance.allHats);
|
||||
hatData.AddRange(HatManager.Instance.allHats);
|
||||
hatData.ForEach(x => x.StoreName = "Vanilla");
|
||||
DestroyableSingleton<HatManager>.Instance.allHats = PrepareArray(hatData, hatBehaviours);
|
||||
HatManager.Instance.allHats = PrepareArray(hatData, hatBehaviours);
|
||||
|
||||
var skinData = new List<SkinData>();
|
||||
skinData.AddRange(DestroyableSingleton<HatManager>.Instance.allSkins);
|
||||
skinData.AddRange(HatManager.Instance.allSkins);
|
||||
skinData.ForEach(x => x.StoreName = "Vanilla");
|
||||
DestroyableSingleton<HatManager>.Instance.allSkins = PrepareArray(skinData, skinBehaviours);
|
||||
HatManager.Instance.allSkins = PrepareArray(skinData, skinBehaviours);
|
||||
|
||||
var visorData = new List<VisorData>();
|
||||
visorData.AddRange(DestroyableSingleton<HatManager>.Instance.allVisors);
|
||||
visorData.AddRange(HatManager.Instance.allVisors);
|
||||
VisorsTabPatches.AddRange(visorBehaviours);
|
||||
DestroyableSingleton<HatManager>.Instance.allVisors = PrepareArray(visorData, visorBehaviours.Select(x=>x.Data).ToList());
|
||||
HatManager.Instance.allVisors = PrepareArray(visorData, visorBehaviours.Select(x=>x.Data).ToList());
|
||||
|
||||
var namePlateData = new List<NamePlateData>();
|
||||
namePlateData.AddRange(DestroyableSingleton<HatManager>.Instance.allNamePlates);
|
||||
namePlateData.AddRange(HatManager.Instance.allNamePlates);
|
||||
NameplatesTabPatches.AddRange(namePlateBehaviours);
|
||||
DestroyableSingleton<HatManager>.Instance.allNamePlates = PrepareArray(namePlateData, namePlateBehaviours.Select(x => x.Data).ToList());
|
||||
HatManager.Instance.allNamePlates = PrepareArray(namePlateData, namePlateBehaviours.Select(x => x.Data).ToList());
|
||||
}
|
||||
|
||||
private static T[] PrepareArray<T>(List<T> data, List<T> behaviours) where T : CosmeticData
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
@@ -7,9 +8,11 @@ using System.Text.RegularExpressions;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Patches.Menu;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Voting;
|
||||
using Reactor.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using Rewired;
|
||||
using Rewired.Data;
|
||||
using TMPro;
|
||||
@@ -53,7 +56,7 @@ public static class Extensions
|
||||
bool isComplete;
|
||||
if (self.amClosing == Minigame.CloseState.Closing)
|
||||
{
|
||||
UnityEngine.Object.Destroy(self.gameObject);
|
||||
self.gameObject.DeepDestroy();
|
||||
return;
|
||||
}
|
||||
if (self.CloseSound && Constants.ShouldPlaySfx())
|
||||
@@ -70,7 +73,7 @@ public static class Extensions
|
||||
}
|
||||
self.amClosing = Minigame.CloseState.Closing;
|
||||
self.logger.Info(string.Concat("Closing minigame ", self.GetType().Name));
|
||||
IAnalyticsReporter analytics = DestroyableSingleton<DebugAnalytics>.Instance.Analytics;
|
||||
IAnalyticsReporter analytics = DebugAnalytics.Instance.Analytics;
|
||||
NetworkedPlayerInfo data = PlayerControl.LocalPlayer.Data;
|
||||
TaskTypes taskType = self.TaskType;
|
||||
float realtimeSinceStartup = Time.realtimeSinceStartup - self.timeOpened;
|
||||
@@ -219,6 +222,135 @@ public static class Extensions
|
||||
return Mathf.Approximately(number, Mathf.Round(number));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroys the object properly.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to destroy.</param>
|
||||
/// <param name="clearGc">Whether to run the garbage collector immediately.</param>
|
||||
public static void DeepDestroy(this GameObject obj, bool clearGc = true)
|
||||
{
|
||||
if (MainMenuManagerPatches.NeedsDeepDestroy)
|
||||
{
|
||||
Coroutines.Start(Nuke(obj, clearGc));
|
||||
}
|
||||
else
|
||||
{
|
||||
obj?.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerator Nuke(GameObject? go, bool clearGc)
|
||||
{
|
||||
if (go == null)
|
||||
yield break;
|
||||
|
||||
try
|
||||
{
|
||||
go.transform.SetParent(null, false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
go.SetActive(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
foreach (var mb in go.GetComponentsInChildren<MonoBehaviour>(true))
|
||||
{
|
||||
if (mb == null)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
mb.StopAllCoroutines();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
mb.enabled = false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var renderer in go.GetComponentsInChildren<Renderer>(true))
|
||||
{
|
||||
if (renderer == null)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var mat in renderer.materials)
|
||||
{
|
||||
if (mat != null)
|
||||
UnityEngine.Object.Destroy(mat);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var filter in go.GetComponentsInChildren<MeshFilter>(true))
|
||||
{
|
||||
if (filter == null)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
var mesh = filter.mesh;
|
||||
if (mesh != null)
|
||||
UnityEngine.Object.Destroy(mesh);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
UnityEngine.Object.Destroy(go);
|
||||
yield return null;
|
||||
if (clearGc)
|
||||
{
|
||||
yield return CoFreeResources();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears up the Garbage Collector manually if necessary.
|
||||
/// </summary>
|
||||
public static void ClearGarbageCollector()
|
||||
{
|
||||
if (!MainMenuManagerPatches.NeedsDeepDestroy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Coroutines.Start(CoFreeResources());
|
||||
}
|
||||
|
||||
private static IEnumerator CoFreeResources()
|
||||
{
|
||||
yield return Resources.UnloadUnusedAssets();
|
||||
|
||||
GC.Collect(0, GCCollectionMode.Forced, blocking: true);
|
||||
GC.WaitForPendingFinalizers();
|
||||
GC.Collect(0, GCCollectionMode.Forced, blocking: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a cache of <see cref="PlayerControl"/>'s <see cref="PlayerVoteData"/> to improve performance.
|
||||
/// </summary>
|
||||
|
||||
@@ -208,7 +208,7 @@ public static class VotingUtils
|
||||
}
|
||||
|
||||
MeetingHud.Instance.TitleText.text =
|
||||
DestroyableSingleton<TranslationController>.Instance.GetString(
|
||||
TranslationController.Instance.GetString(
|
||||
StringNames.MeetingVotingResults,
|
||||
Il2CppSystem.Array.Empty<Il2CppSystem.Object>());
|
||||
|
||||
|
||||
Reference in new issue
Block a user