mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Screenshot manager plugin
This commit is contained in:
1 parent
6423eb583f
commit
89c11bff4e
5 files changed
+170
-5
No files matched your search
@@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorCorrector", "Plugins\C
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SliderUnlocker", "Plugins\SliderUnlocker\SliderUnlocker.csproj", "{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SliderUnlocker", "Plugins\SliderUnlocker\SliderUnlocker.csproj", "{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Screencap", "Plugins\Screencap\Screencap.csproj", "{6A9D08C0-4482-4D1A-9368-9F41B7126F9E}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||||
BepInEx.Common\BepInEx.Common.projitems*{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}*SharedItemsImports = 4
|
BepInEx.Common\BepInEx.Common.projitems*{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}*SharedItemsImports = 4
|
||||||
@@ -60,6 +62,10 @@ Global
|
|||||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Release|Any CPU.Build.0 = Release|Any CPU
|
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6A9D08C0-4482-4D1A-9368-9F41B7126F9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6A9D08C0-4482-4D1A-9368-9F41B7126F9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6A9D08C0-4482-4D1A-9368-9F41B7126F9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6A9D08C0-4482-4D1A-9368-9F41B7126F9E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -70,6 +76,7 @@ Global
|
|||||||
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||||
{6809B5DC-358C-45C5-B04C-0B7027596A8B} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
{6809B5DC-358C-45C5-B04C-0B7027596A8B} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||||
|
{6A9D08C0-4482-4D1A-9368-9F41B7126F9E} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {55AC11EF-F568-4C79-A356-7ED9510145B1}
|
SolutionGuid = {55AC11EF-F568-4C79-A356-7ED9510145B1}
|
||||||
|
|||||||
@@ -53,11 +53,7 @@ namespace DynamicTranslationLoader
|
|||||||
|
|
||||||
void OnUpdate()
|
void OnUpdate()
|
||||||
{
|
{
|
||||||
if (UnityEngine.Event.current.Equals(Event.KeyboardEvent("f9")))
|
if (UnityEngine.Event.current.Equals(Event.KeyboardEvent("f10")))
|
||||||
{
|
|
||||||
TranslateAll();
|
|
||||||
}
|
|
||||||
else if (UnityEngine.Event.current.Equals(Event.KeyboardEvent("f10")))
|
|
||||||
{
|
{
|
||||||
Dump();
|
Dump();
|
||||||
Console.WriteLine($"Text dumped to \"{Path.GetFullPath("dumped-tl.txt")}\"");
|
Console.WriteLine($"Text dumped to \"{Path.GetFullPath("dumped-tl.txt")}\"");
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Screencap")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Screencap")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("6a9d08c0-4482-4d1a-9368-9f41b7126f9e")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{6A9D08C0-4482-4D1A-9368-9F41B7126F9E}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Screencap</RootNamespace>
|
||||||
|
<AssemblyName>Screencap</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>D:\koikatu\BepInEx\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>D:\koikatu\BepInEx\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="UnityEngine">
|
||||||
|
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\UnityEngine.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ScreenshotManager.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\BepInEx\BepInEx.csproj">
|
||||||
|
<Project>{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}</Project>
|
||||||
|
<Name>BepInEx</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
using BepInEx;
|
||||||
|
using BepInEx.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Screencap
|
||||||
|
{
|
||||||
|
public class ScreenshotManager : BaseUnityPlugin
|
||||||
|
{
|
||||||
|
public override string Name => "Screenshot Manager";
|
||||||
|
|
||||||
|
private string screenshotDir = Utility.CombinePaths(Utility.ExecutingDirectory, "UserData", "cap");
|
||||||
|
|
||||||
|
public ScreenshotManager()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(screenshotDir))
|
||||||
|
Directory.CreateDirectory(screenshotDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LateUpdate()
|
||||||
|
{
|
||||||
|
if (UnityEngine.Event.current.Equals(Event.KeyboardEvent("f9")))
|
||||||
|
{
|
||||||
|
string filename = Path.Combine(screenshotDir, $"Koikatsu -{DateTime.Now.ToString("yyyy-mm-dd-HH-mm-ss")}.png");
|
||||||
|
TakeScreenshot(filename);
|
||||||
|
}
|
||||||
|
else if (UnityEngine.Event.current.Equals(Event.KeyboardEvent("f11")))
|
||||||
|
{
|
||||||
|
string filename = Path.Combine(screenshotDir, $"Koikatsu Char-{DateTime.Now.ToString("yyyy-mm-dd-HH-mm-ss")}.png");
|
||||||
|
TakeCharScreenshot(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TakeScreenshot(string filename)
|
||||||
|
{
|
||||||
|
UnityEngine.Application.CaptureScreenshot(filename);
|
||||||
|
Console.WriteLine($"Screenshot saved to {filename}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TakeCharScreenshot(string filename)
|
||||||
|
{
|
||||||
|
Camera.main.backgroundColor = Color.clear;
|
||||||
|
var tex = RenderCamera(Camera.main);
|
||||||
|
File.WriteAllBytes(filename, tex.EncodeToPNG());
|
||||||
|
Destroy(tex);
|
||||||
|
Console.WriteLine($"Character screenshot saved to {filename}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D RenderCamera(Camera cam)
|
||||||
|
{
|
||||||
|
float oldaspect = cam.aspect;
|
||||||
|
cam.targetTexture = new RenderTexture(1024, 1024, 32); //((int)cam.pixelRect.width, (int)cam.pixelRect.height, 32);
|
||||||
|
cam.aspect = cam.targetTexture.width / (float)cam.targetTexture.height;
|
||||||
|
RenderTexture currentRT = RenderTexture.active;
|
||||||
|
RenderTexture.active = cam.targetTexture;
|
||||||
|
|
||||||
|
cam.Render();
|
||||||
|
Texture2D image = new Texture2D(cam.targetTexture.width, cam.targetTexture.height);
|
||||||
|
image.ReadPixels(new Rect(0, 0, cam.targetTexture.width, cam.targetTexture.height), 0, 0);
|
||||||
|
image.Apply();
|
||||||
|
RenderTexture.active = currentRT;
|
||||||
|
Destroy(cam.targetTexture);
|
||||||
|
cam.targetTexture = null;
|
||||||
|
cam.aspect = oldaspect;
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user