Skip to content

Commit

Permalink
Fix Screencap compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
DeathWeasel1337 committed May 11, 2021
1 parent 33ef3ba commit 4c631f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/KK_Fix_Eyebrows/EyebrowFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public class EyebrowFix : BaseUnityPlugin
- EC version
- Adapt code for eyeliners as well
- Rename plugin since EyebrowFix doesn't make sense if it also works on eyeliners
- Ask essu to look in to compatiblity with screenshot plugin
- Take all the credit
- Fix compatibility with MaterialEditor disabled renderers
*/

public static RenderTexture rt;
Expand All @@ -44,21 +43,31 @@ internal void Awake()
//TODO: only do any of this allocation and deallocation of rendertextures when in a scene with an actual camera :^)
//pre render
private void Update()
{
rt = RenderTexture.GetTemporary(Screen.width, Screen.height, 0, RenderTextureFormat.ARGBHalf);
RenderTexture.active = rt;
GL.Clear(true, true, Color.clear);
RenderTexture.active = null;
}

//post render
private void OnGUI()
{
if (rt != null)
{
RenderTexture.ReleaseTemporary(rt);
rt = null;
}

int rx;
int ry;

if (Screencap.ScreenshotManager.KeyCaptureAlpha.Value.IsDown())
{
rx = Screencap. ScreenshotManager.ResolutionX.Value * Screencap.ScreenshotManager.DownscalingRate.Value;
ry = Screencap.ScreenshotManager.ResolutionY.Value * Screencap.ScreenshotManager.DownscalingRate.Value;
}
else
{
rx = Screen.width;
ry = Screen.height;
}
rt = RenderTexture.GetTemporary(rx, ry, 0, RenderTextureFormat.ARGBHalf);
var rta = RenderTexture.active;
RenderTexture.active = rt;
GL.Clear(true, true, Color.clear);
RenderTexture.active = rta;
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/KK_Fix_Eyebrows/KK_Fix_Eyebrows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<HintPath>..\..\packages\IllusionModdingAPI.KKAPI.1.18.0\lib\net35\KKAPI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Screencap">
<HintPath>..\..\lib\Screencap.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand Down

0 comments on commit 4c631f2

Please sign in to comment.