1
0
mirror of https://github.com/originalnicodr/CinematicUnityExplorer.git synced 2025-07-18 17:38:01 +08:00

Improved post-processing logging messages and improved compatibility with Hellpoint and potentially more games.

This commit is contained in:
originalnicodr
2024-05-05 23:36:21 -03:00
parent 271261307d
commit 66773b300f
2 changed files with 26 additions and 34 deletions

View File

@ -41,13 +41,13 @@ namespace UnityExplorer.UI.Panels
List<Canvas> disabledCanvases;
Toggle HUDToggle;
CacheMethod captureScreenshotFunction = null;
MethodInfo captureScreenshotFunction = null;
int superSizeValue = 2;
public ScreenshotState screenshotStatus;
Toggle HighLodToggle;
object qualitySettings = null;
CacheProperty lodBias = null;
PropertyInfo lodBias = null;
// We save the current properties of the Renderers and Lights to restore them after editing them with togglers
internal Dictionary<Renderer, bool> renderersReceiveShadows = new();
@ -92,56 +92,39 @@ namespace UnityExplorer.UI.Panels
}
private void TakeScreenshot(){
MethodInfo methodInfo = captureScreenshotFunction.MethodInfo;
string filename = DateTime.Now.ToString("yyyy-M-d HH-mm-ss");
string screenshotsPath = Path.Combine(ExplorerCore.ExplorerFolder, "Screenshots");
System.IO.Directory.CreateDirectory(screenshotsPath);
object[] args = {$"{screenshotsPath}\\{filename}.png", superSizeValue};
methodInfo.Invoke(captureScreenshotFunction.DeclaringInstance, args);
try {
captureScreenshotFunction.Invoke(qualitySettings, args);
}
catch { ExplorerCore.LogWarning("Failed to take a screenshot. Chances are the method has been stripped."); }
}
private void FindCaptureScreenshotFunction(){
try {
object screenCaptureClass = ReflectionUtility.GetTypeByName("UnityEngine.ScreenCapture");
Type screenCaptureType = screenCaptureClass is Type type ? type : screenCaptureClass.GetActualType();
ReflectionInspector inspector = Pool<ReflectionInspector>.Borrow();
List<CacheMember> members = CacheMemberFactory.GetCacheMembers(screenCaptureType, inspector);
foreach (CacheMember member in members){
if (member is CacheMethod methodMember){
if (methodMember.NameForFiltering == "ScreenCapture.CaptureScreenshot(string, int)"){
captureScreenshotFunction = methodMember;
break;
}
}
}
captureScreenshotFunction = screenCaptureType.GetMethod("CaptureScreenshot", new Type[] {typeof(string), typeof(int)});
}
catch { ExplorerCore.Log("Couldn't find the ScreenCapture class.");}
catch { ExplorerCore.Log("Couldn't find the ScreenCapture class."); }
}
private void FindQualitySettings(){
qualitySettings = ReflectionUtility.GetTypeByName("UnityEngine.QualitySettings");
}
private void FindLodBias(){
Type qualitySettingsType = qualitySettings is Type type ? type : qualitySettings.GetActualType();
ReflectionInspector inspector = Pool<ReflectionInspector>.Borrow();
List<CacheMember> members = CacheMemberFactory.GetCacheMembers(qualitySettingsType, inspector);
foreach (CacheMember member in members){
if (member is CacheProperty propertyMember && propertyMember.NameForFiltering == "QualitySettings.lodBias"){
lodBias = propertyMember;
break;
}
}
}
private void ToogleHighLods(bool areHighLodsOn){
if (qualitySettings == null) FindQualitySettings();
if (lodBias == null) FindLodBias();
if (lodBias == null){
Type qualitySettingsType = qualitySettings is Type type ? type : qualitySettings.GetActualType();
lodBias = qualitySettingsType.GetProperty("lodBias");
}
lodBias.TrySetUserValue(areHighLodsOn ? 10000 : 1);
lodBias.SetValue(null, areHighLodsOn ? 10000 : 1, null);
}
private void ToggleAllMeshesCastAndRecieveShadows(bool enable){

View File

@ -31,6 +31,7 @@ namespace UnityExplorer.UI.Panels
public static Dictionary<string,List<PPEffect>> postProcessingEffects = null;
static ButtonRef updateEffects;
List<GameObject> UIElements = new List<GameObject>();
public bool foundAnyEffect;
public class PPEffect
{
@ -46,8 +47,6 @@ namespace UnityExplorer.UI.Panels
List<CacheMember> members = CacheMemberFactory.GetCacheMembers(objType, inspector);
foreach (CacheMember member in members){
//ExplorerCore.LogWarning(entry.NameForFiltering);
if (member.NameForFiltering.EndsWith(".active")){
member.Evaluate();
Active = member;
@ -68,6 +67,8 @@ namespace UnityExplorer.UI.Panels
}
public void UpdatePPElements(){
foundAnyEffect = false;
if(postProcessingEffects != null){
// We turn the effects we had back on so they get captured again on refresh
foreach (List<PPEffect> effects in postProcessingEffects.Values){
@ -168,6 +169,10 @@ namespace UnityExplorer.UI.Panels
catch {}
}
if (!foundAnyEffect){
ExplorerCore.Log("Couldn't find any standard post-processing effect classes.");
}
BuildEffectTogglers();
}
@ -189,8 +194,12 @@ namespace UnityExplorer.UI.Panels
postProcessingEffects[effect].Add(entry);
}
}
foundAnyEffect = true;
}
catch {
// ExplorerCore.Log($"Couldn't find {baseClass}.{effect}");
}
catch { ExplorerCore.Log($"Couldn't find {baseClass}.{effect}");}
}
private void SetEffect(bool value, List<PPEffect> effects){