SHA256
Document Harmony Patches
This commit is contained in:
1 parent
8deb64fd4d
commit
d2bd655118
19 files changed
+499
-4
No files matched your search
@@ -6,10 +6,28 @@ using UnityEngine.UI;
|
||||
|
||||
namespace ADOFAIRenderer.Patch.Game;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the "Render" button to the level editor toolbar.
|
||||
/// <para>
|
||||
/// Patched member: <c>scnEditor.Start()</c>, the editor scene setup (it wires the toolbar buttons, including
|
||||
/// <c>buttonExit</c>). The postfix clones the exit button next to it and makes the clone start a render.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Always active except when the mod features are disabled (<see cref="RenderMod.IsFeatureDisabled"/>, set from the
|
||||
/// driver warning dialog). Runs on the Unity main thread each time the editor scene starts.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(scnEditor))]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static class scnEditorPatch
|
||||
{
|
||||
/// <summary>
|
||||
/// Postfix of <c>scnEditor.Start</c>: instantiates a copy of <c>buttonExit</c> under the same parent, named
|
||||
/// <c>buttonRender</c>, whose click handler is <see cref="RenderManager.StartRender"/>, 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.
|
||||
/// </summary>
|
||||
/// <param name="__instance">The editor scene component.</param>
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("Start")]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
@@ -38,8 +56,9 @@ public static class scnEditorPatch
|
||||
var images = buttonObj.GetComponentsInChildren<Image>();
|
||||
if (images.Length <= 1) return;
|
||||
|
||||
// images[0] is the background on the root, images[1] is the icon on the child.
|
||||
// Sprite path: the icon of the editor's MoveCamera level event, loaded from the game's Resources.
|
||||
// ReSharper disable once Unity.UnknownResource
|
||||
// images[0] is the background on the root, images[1] is the icon on the child
|
||||
var sprite = Resources.Load<Sprite>("LevelEditor/LevelEvents/MoveCamera");
|
||||
if (sprite == null) return;
|
||||
|
||||
|
||||
Reference in new issue
Block a user