using ADOFAIRenderer.Core; using HarmonyLib; using MelonLoader; using UnityEngine; using UnityEngine.UI; namespace ADOFAIRenderer.Patch.Game; /// /// Adds the "Render" button to the level editor toolbar. /// /// Patched member: scnEditor.Start(), the editor scene setup (it wires the toolbar buttons, including /// buttonExit). The postfix clones the exit button next to it and makes the clone start a render. /// /// /// Always active except when the mod features are disabled (, set from the /// driver warning dialog). Runs on the Unity main thread each time the editor scene starts. /// /// [HarmonyPatch(typeof(scnEditor))] // ReSharper disable once InconsistentNaming public static class scnEditorPatch { /// /// Postfix of scnEditor.Start: instantiates a copy of buttonExit under the same parent, named /// buttonRender, whose click handler is , and replaces its icon with the /// editor's MoveCamera event sprite (24 x 24 units). Logs a message and adds nothing when the editor or exit button is missing. /// When the icon child or the sprite is not found, the button keeps the exit icon. /// /// The editor scene component. [HarmonyPostfix] [HarmonyPatch("Start")] // ReSharper disable once InconsistentNaming public static void AddButtonRender(scnEditor __instance) { if (RenderMod.IsFeatureDisabled) return; if (!__instance || !__instance.buttonExit) { Melon.Logger.Msg("Cannot create render button in scnEditor."); return; } var cloneTarget = __instance.buttonExit!.gameObject; var buttonContainer = cloneTarget.transform.parent!; var buttonObj = Object.Instantiate(cloneTarget, buttonContainer)!; buttonObj.name = "buttonRender"; var button = buttonObj.GetComponent