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:
@ -41,13 +41,13 @@ namespace UnityExplorer.UI.Panels
|
|||||||
List<Canvas> disabledCanvases;
|
List<Canvas> disabledCanvases;
|
||||||
Toggle HUDToggle;
|
Toggle HUDToggle;
|
||||||
|
|
||||||
CacheMethod captureScreenshotFunction = null;
|
MethodInfo captureScreenshotFunction = null;
|
||||||
int superSizeValue = 2;
|
int superSizeValue = 2;
|
||||||
public ScreenshotState screenshotStatus;
|
public ScreenshotState screenshotStatus;
|
||||||
|
|
||||||
Toggle HighLodToggle;
|
Toggle HighLodToggle;
|
||||||
object qualitySettings = null;
|
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
|
// We save the current properties of the Renderers and Lights to restore them after editing them with togglers
|
||||||
internal Dictionary<Renderer, bool> renderersReceiveShadows = new();
|
internal Dictionary<Renderer, bool> renderersReceiveShadows = new();
|
||||||
@ -92,56 +92,39 @@ namespace UnityExplorer.UI.Panels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void TakeScreenshot(){
|
private void TakeScreenshot(){
|
||||||
MethodInfo methodInfo = captureScreenshotFunction.MethodInfo;
|
|
||||||
string filename = DateTime.Now.ToString("yyyy-M-d HH-mm-ss");
|
string filename = DateTime.Now.ToString("yyyy-M-d HH-mm-ss");
|
||||||
|
|
||||||
string screenshotsPath = Path.Combine(ExplorerCore.ExplorerFolder, "Screenshots");
|
string screenshotsPath = Path.Combine(ExplorerCore.ExplorerFolder, "Screenshots");
|
||||||
System.IO.Directory.CreateDirectory(screenshotsPath);
|
System.IO.Directory.CreateDirectory(screenshotsPath);
|
||||||
|
|
||||||
object[] args = {$"{screenshotsPath}\\{filename}.png", superSizeValue};
|
object[] args = {$"{screenshotsPath}\\{filename}.png", superSizeValue};
|
||||||
|
try {
|
||||||
methodInfo.Invoke(captureScreenshotFunction.DeclaringInstance, args);
|
captureScreenshotFunction.Invoke(qualitySettings, args);
|
||||||
|
}
|
||||||
|
catch { ExplorerCore.LogWarning("Failed to take a screenshot. Chances are the method has been stripped."); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FindCaptureScreenshotFunction(){
|
private void FindCaptureScreenshotFunction(){
|
||||||
try {
|
try {
|
||||||
object screenCaptureClass = ReflectionUtility.GetTypeByName("UnityEngine.ScreenCapture");
|
object screenCaptureClass = ReflectionUtility.GetTypeByName("UnityEngine.ScreenCapture");
|
||||||
Type screenCaptureType = screenCaptureClass is Type type ? type : screenCaptureClass.GetActualType();
|
Type screenCaptureType = screenCaptureClass is Type type ? type : screenCaptureClass.GetActualType();
|
||||||
ReflectionInspector inspector = Pool<ReflectionInspector>.Borrow();
|
captureScreenshotFunction = screenCaptureType.GetMethod("CaptureScreenshot", new Type[] {typeof(string), typeof(int)});
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch { ExplorerCore.Log("Couldn't find the ScreenCapture class.");}
|
catch { ExplorerCore.Log("Couldn't find the ScreenCapture class."); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FindQualitySettings(){
|
private void FindQualitySettings(){
|
||||||
qualitySettings = ReflectionUtility.GetTypeByName("UnityEngine.QualitySettings");
|
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){
|
private void ToogleHighLods(bool areHighLodsOn){
|
||||||
if (qualitySettings == null) FindQualitySettings();
|
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){
|
private void ToggleAllMeshesCastAndRecieveShadows(bool enable){
|
||||||
|
@ -31,6 +31,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
public static Dictionary<string,List<PPEffect>> postProcessingEffects = null;
|
public static Dictionary<string,List<PPEffect>> postProcessingEffects = null;
|
||||||
static ButtonRef updateEffects;
|
static ButtonRef updateEffects;
|
||||||
List<GameObject> UIElements = new List<GameObject>();
|
List<GameObject> UIElements = new List<GameObject>();
|
||||||
|
public bool foundAnyEffect;
|
||||||
|
|
||||||
public class PPEffect
|
public class PPEffect
|
||||||
{
|
{
|
||||||
@ -46,8 +47,6 @@ namespace UnityExplorer.UI.Panels
|
|||||||
List<CacheMember> members = CacheMemberFactory.GetCacheMembers(objType, inspector);
|
List<CacheMember> members = CacheMemberFactory.GetCacheMembers(objType, inspector);
|
||||||
|
|
||||||
foreach (CacheMember member in members){
|
foreach (CacheMember member in members){
|
||||||
//ExplorerCore.LogWarning(entry.NameForFiltering);
|
|
||||||
|
|
||||||
if (member.NameForFiltering.EndsWith(".active")){
|
if (member.NameForFiltering.EndsWith(".active")){
|
||||||
member.Evaluate();
|
member.Evaluate();
|
||||||
Active = member;
|
Active = member;
|
||||||
@ -68,6 +67,8 @@ namespace UnityExplorer.UI.Panels
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void UpdatePPElements(){
|
public void UpdatePPElements(){
|
||||||
|
foundAnyEffect = false;
|
||||||
|
|
||||||
if(postProcessingEffects != null){
|
if(postProcessingEffects != null){
|
||||||
// We turn the effects we had back on so they get captured again on refresh
|
// We turn the effects we had back on so they get captured again on refresh
|
||||||
foreach (List<PPEffect> effects in postProcessingEffects.Values){
|
foreach (List<PPEffect> effects in postProcessingEffects.Values){
|
||||||
@ -168,6 +169,10 @@ namespace UnityExplorer.UI.Panels
|
|||||||
catch {}
|
catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!foundAnyEffect){
|
||||||
|
ExplorerCore.Log("Couldn't find any standard post-processing effect classes.");
|
||||||
|
}
|
||||||
|
|
||||||
BuildEffectTogglers();
|
BuildEffectTogglers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,8 +194,12 @@ namespace UnityExplorer.UI.Panels
|
|||||||
postProcessingEffects[effect].Add(entry);
|
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){
|
private void SetEffect(bool value, List<PPEffect> effects){
|
||||||
|
Reference in New Issue
Block a user