Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #69 from PuddingVR/master
Browse files Browse the repository at this point in the history
Patch to allow screenshots with third person camera
  • Loading branch information
RequiDev authored Jul 12, 2022
2 parents ccb38f4 + e74c822 commit f8a8ca7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ReModCE/Components/ThirdPersonComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ReMod.Core.UI.QuickMenu;
using ReModCE.Managers;
using UnityEngine;
using CameraTakePhotoEnumerator = VRC.UserCamera.CameraUtil._TakeScreenShot_d__5;

namespace ReModCE.Components
{
Expand All @@ -16,12 +17,12 @@ internal enum ThirdPersonMode

internal class ThirdPersonComponent : ModComponent
{
private Camera _cameraBack;
private Camera _cameraFront;
private static Camera _cameraBack;
private static Camera _cameraFront;
private Camera _referenceCamera;
private Camera _photoCamera;

private ThirdPersonMode _cameraSetup;
private static ThirdPersonMode _cameraSetup;

private ConfigValue<bool> EnableThirdpersonHotkey;
private ReMenuToggle _hotkeyToggle;
Expand All @@ -42,6 +43,9 @@ public ThirdPersonComponent()
SetThirdPersonMode(ThirdPersonMode.Off);
}
};

ReModCE.Harmony.Patch(typeof (CameraTakePhotoEnumerator).GetMethod("MoveNext"),
GetLocalPatch(nameof(CameraEnumeratorMoveNextPatch)));
}

public override void OnUiManagerInit(UiManager uiManager)
Expand Down Expand Up @@ -158,5 +162,13 @@ public override void OnUpdate()
HandleHotkeys();
HandleThirdperson();
}

private static void CameraEnumeratorMoveNextPatch(ref CameraTakePhotoEnumerator __instance)
{
if(_cameraSetup == ThirdPersonMode.Off)
return;

__instance.field_Public_Camera_0 = _cameraSetup == ThirdPersonMode.Back ? _cameraBack : _cameraFront;
}
}
}

0 comments on commit f8a8ca7

Please sign in to comment.