加入很多新内容,这波一块交了
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class GlobalAfterimageInstaller
|
||||
{
|
||||
private const string RendererDataPath = "Assets/Settings/Renderer2D.asset";
|
||||
private const string GameplayVolumeProfilePath = "Assets/Scenes/gamePlay_gamePlay/gpGV.asset";
|
||||
private static bool installScheduled;
|
||||
|
||||
static GlobalAfterimageInstaller()
|
||||
{
|
||||
ScheduleInstall();
|
||||
}
|
||||
|
||||
[MenuItem("Bansonic/Rendering/Install Global Afterimage")]
|
||||
public static void EnsureInstalledMenu()
|
||||
{
|
||||
EnsureInstalled();
|
||||
}
|
||||
|
||||
private static void ScheduleInstall()
|
||||
{
|
||||
if (installScheduled)
|
||||
return;
|
||||
|
||||
installScheduled = true;
|
||||
EditorApplication.delayCall += RunScheduledInstall;
|
||||
}
|
||||
|
||||
private static void RunScheduledInstall()
|
||||
{
|
||||
installScheduled = false;
|
||||
EnsureInstalled();
|
||||
}
|
||||
|
||||
private static void EnsureInstalled()
|
||||
{
|
||||
if (EditorApplication.isCompiling || BuildPipeline.isBuildingPlayer)
|
||||
{
|
||||
ScheduleInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsUnsafeSelectionActive())
|
||||
{
|
||||
ScheduleInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureRendererFeatureInstalled();
|
||||
EnsureVolumeOverrideInstalled();
|
||||
}
|
||||
|
||||
private static void EnsureRendererFeatureInstalled()
|
||||
{
|
||||
ScriptableRendererData rendererData = AssetDatabase.LoadAssetAtPath<ScriptableRendererData>(RendererDataPath);
|
||||
if (rendererData == null)
|
||||
return;
|
||||
|
||||
if (!rendererData.TryGetRendererFeature<GlobalAfterimageRendererFeature>(out GlobalAfterimageRendererFeature feature))
|
||||
{
|
||||
feature = ScriptableObject.CreateInstance<GlobalAfterimageRendererFeature>();
|
||||
feature.name = "Global Afterimage Renderer Feature";
|
||||
AssetDatabase.AddObjectToAsset(feature, rendererData);
|
||||
rendererData.rendererFeatures.Add(feature);
|
||||
rendererData.SetDirty();
|
||||
EditorUtility.SetDirty(feature);
|
||||
EditorUtility.SetDirty(rendererData);
|
||||
TryValidateRendererFeatures(rendererData);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.ImportAsset(RendererDataPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (feature.renderPassEvent != RenderPassEvent.AfterRenderingPostProcessing)
|
||||
{
|
||||
feature.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing;
|
||||
rendererData.SetDirty();
|
||||
EditorUtility.SetDirty(feature);
|
||||
EditorUtility.SetDirty(rendererData);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureVolumeOverrideInstalled()
|
||||
{
|
||||
VolumeProfile profile = AssetDatabase.LoadAssetAtPath<VolumeProfile>(GameplayVolumeProfilePath);
|
||||
if (profile == null)
|
||||
return;
|
||||
|
||||
RemoveNullVolumeComponents(profile);
|
||||
|
||||
if (profile.TryGet<GlobalAfterimageVolume>(out _))
|
||||
return;
|
||||
|
||||
GlobalAfterimageVolume component = profile.Add<GlobalAfterimageVolume>(true);
|
||||
component.active = false;
|
||||
component.opacity.overrideState = true;
|
||||
component.opacity.value = 0f;
|
||||
component.scale.overrideState = true;
|
||||
component.scale.value = 1.05f;
|
||||
component.affectSceneView.overrideState = true;
|
||||
component.affectSceneView.value = false;
|
||||
EditorUtility.SetDirty(component);
|
||||
EditorUtility.SetDirty(profile);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
private static void RemoveNullVolumeComponents(VolumeProfile profile)
|
||||
{
|
||||
SerializedObject serializedObject = new SerializedObject(profile);
|
||||
SerializedProperty componentsProperty = serializedObject.FindProperty("components");
|
||||
if (componentsProperty == null || !componentsProperty.isArray)
|
||||
return;
|
||||
|
||||
bool removed = false;
|
||||
for (int i = componentsProperty.arraySize - 1; i >= 0; i--)
|
||||
{
|
||||
SerializedProperty element = componentsProperty.GetArrayElementAtIndex(i);
|
||||
if (element.objectReferenceValue != null)
|
||||
continue;
|
||||
|
||||
componentsProperty.DeleteArrayElementAtIndex(i);
|
||||
removed = true;
|
||||
}
|
||||
|
||||
if (!removed)
|
||||
return;
|
||||
|
||||
serializedObject.ApplyModifiedPropertiesWithoutUndo();
|
||||
EditorUtility.SetDirty(profile);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
private static void TryValidateRendererFeatures(ScriptableRendererData rendererData)
|
||||
{
|
||||
MethodInfo validateMethod = typeof(ScriptableRendererData).GetMethod("ValidateRendererFeatures", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
validateMethod?.Invoke(rendererData, null);
|
||||
}
|
||||
|
||||
private static bool IsUnsafeSelectionActive()
|
||||
{
|
||||
Object activeObject = Selection.activeObject;
|
||||
if (activeObject is VolumeProfile || activeObject is Volume)
|
||||
return true;
|
||||
|
||||
GameObject activeGameObject = Selection.activeGameObject;
|
||||
if (activeGameObject == null)
|
||||
return false;
|
||||
|
||||
return activeGameObject.TryGetComponent<Volume>(out _);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5a6ce7542914bd428842b45057360d0
|
||||
@@ -0,0 +1,167 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class GlobalDistortionInstaller
|
||||
{
|
||||
private const string RendererDataPath = "Assets/Settings/Renderer2D.asset";
|
||||
private const string GameplayVolumeProfilePath = "Assets/Scenes/gamePlay_gamePlay/gpGV.asset";
|
||||
private static bool installScheduled;
|
||||
|
||||
static GlobalDistortionInstaller()
|
||||
{
|
||||
ScheduleInstall();
|
||||
}
|
||||
|
||||
[MenuItem("Bansonic/Rendering/Install Global Distortion")]
|
||||
public static void EnsureInstalledMenu()
|
||||
{
|
||||
EnsureInstalled();
|
||||
}
|
||||
|
||||
private static void ScheduleInstall()
|
||||
{
|
||||
if (installScheduled)
|
||||
return;
|
||||
|
||||
installScheduled = true;
|
||||
EditorApplication.delayCall += RunScheduledInstall;
|
||||
}
|
||||
|
||||
private static void RunScheduledInstall()
|
||||
{
|
||||
installScheduled = false;
|
||||
EnsureInstalled();
|
||||
}
|
||||
|
||||
private static void EnsureInstalled()
|
||||
{
|
||||
if (EditorApplication.isCompiling || BuildPipeline.isBuildingPlayer)
|
||||
{
|
||||
ScheduleInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsUnsafeSelectionActive())
|
||||
{
|
||||
ScheduleInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureRendererFeatureInstalled();
|
||||
EnsureVolumeOverrideInstalled();
|
||||
}
|
||||
|
||||
private static void EnsureRendererFeatureInstalled()
|
||||
{
|
||||
ScriptableRendererData rendererData = AssetDatabase.LoadAssetAtPath<ScriptableRendererData>(RendererDataPath);
|
||||
if (rendererData == null)
|
||||
return;
|
||||
|
||||
if (!rendererData.TryGetRendererFeature<GlobalDistortionRendererFeature>(out GlobalDistortionRendererFeature feature))
|
||||
{
|
||||
feature = ScriptableObject.CreateInstance<GlobalDistortionRendererFeature>();
|
||||
feature.name = "Global Distortion Renderer Feature";
|
||||
AssetDatabase.AddObjectToAsset(feature, rendererData);
|
||||
rendererData.rendererFeatures.Add(feature);
|
||||
rendererData.SetDirty();
|
||||
EditorUtility.SetDirty(feature);
|
||||
EditorUtility.SetDirty(rendererData);
|
||||
TryValidateRendererFeatures(rendererData);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.ImportAsset(RendererDataPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (feature.renderPassEvent != RenderPassEvent.AfterRenderingPostProcessing)
|
||||
{
|
||||
feature.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing;
|
||||
rendererData.SetDirty();
|
||||
EditorUtility.SetDirty(feature);
|
||||
EditorUtility.SetDirty(rendererData);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureVolumeOverrideInstalled()
|
||||
{
|
||||
VolumeProfile profile = AssetDatabase.LoadAssetAtPath<VolumeProfile>(GameplayVolumeProfilePath);
|
||||
if (profile == null)
|
||||
return;
|
||||
|
||||
RemoveNullVolumeComponents(profile);
|
||||
|
||||
if (profile.TryGet<GlobalDistortionVolume>(out _))
|
||||
return;
|
||||
|
||||
GlobalDistortionVolume component = profile.Add<GlobalDistortionVolume>(true);
|
||||
component.active = false;
|
||||
component.intensity.overrideState = true;
|
||||
component.intensity.value = 0f;
|
||||
component.noiseStrength.overrideState = true;
|
||||
component.noiseStrength.value = 0.16f;
|
||||
component.radialStrength.overrideState = true;
|
||||
component.radialStrength.value = 0.35f;
|
||||
component.noiseScale.overrideState = true;
|
||||
component.noiseScale.value = 12f;
|
||||
component.center.overrideState = true;
|
||||
component.center.value = new Vector2(0.5f, 0.5f);
|
||||
component.edgeFade.overrideState = true;
|
||||
component.edgeFade.value = 1.25f;
|
||||
component.affectSceneView.overrideState = true;
|
||||
component.affectSceneView.value = false;
|
||||
EditorUtility.SetDirty(component);
|
||||
EditorUtility.SetDirty(profile);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
private static void RemoveNullVolumeComponents(VolumeProfile profile)
|
||||
{
|
||||
SerializedObject serializedObject = new SerializedObject(profile);
|
||||
SerializedProperty componentsProperty = serializedObject.FindProperty("components");
|
||||
if (componentsProperty == null || !componentsProperty.isArray)
|
||||
return;
|
||||
|
||||
bool removed = false;
|
||||
for (int i = componentsProperty.arraySize - 1; i >= 0; i--)
|
||||
{
|
||||
SerializedProperty element = componentsProperty.GetArrayElementAtIndex(i);
|
||||
if (element.objectReferenceValue != null)
|
||||
continue;
|
||||
|
||||
componentsProperty.DeleteArrayElementAtIndex(i);
|
||||
removed = true;
|
||||
}
|
||||
|
||||
if (!removed)
|
||||
return;
|
||||
|
||||
serializedObject.ApplyModifiedPropertiesWithoutUndo();
|
||||
EditorUtility.SetDirty(profile);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
private static void TryValidateRendererFeatures(ScriptableRendererData rendererData)
|
||||
{
|
||||
MethodInfo validateMethod = typeof(ScriptableRendererData).GetMethod("ValidateRendererFeatures", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
validateMethod?.Invoke(rendererData, null);
|
||||
}
|
||||
|
||||
private static bool IsUnsafeSelectionActive()
|
||||
{
|
||||
Object activeObject = Selection.activeObject;
|
||||
if (activeObject is VolumeProfile || activeObject is Volume)
|
||||
return true;
|
||||
|
||||
GameObject activeGameObject = Selection.activeGameObject;
|
||||
if (activeGameObject == null)
|
||||
return false;
|
||||
|
||||
return activeGameObject.TryGetComponent<Volume>(out _);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8da344594051c8647abdb52bec165007
|
||||
@@ -0,0 +1,167 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class GlobalGlitchInstaller
|
||||
{
|
||||
private const string RendererDataPath = "Assets/Settings/Renderer2D.asset";
|
||||
private const string GameplayVolumeProfilePath = "Assets/Scenes/gamePlay_gamePlay/gpGV.asset";
|
||||
private static bool installScheduled;
|
||||
|
||||
static GlobalGlitchInstaller()
|
||||
{
|
||||
ScheduleInstall();
|
||||
}
|
||||
|
||||
[MenuItem("Bansonic/Rendering/Install Global Glitch")]
|
||||
public static void EnsureInstalledMenu()
|
||||
{
|
||||
EnsureInstalled();
|
||||
}
|
||||
|
||||
private static void ScheduleInstall()
|
||||
{
|
||||
if (installScheduled)
|
||||
return;
|
||||
|
||||
installScheduled = true;
|
||||
EditorApplication.delayCall += RunScheduledInstall;
|
||||
}
|
||||
|
||||
private static void RunScheduledInstall()
|
||||
{
|
||||
installScheduled = false;
|
||||
EnsureInstalled();
|
||||
}
|
||||
|
||||
private static void EnsureInstalled()
|
||||
{
|
||||
if (EditorApplication.isCompiling || BuildPipeline.isBuildingPlayer)
|
||||
{
|
||||
ScheduleInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsUnsafeSelectionActive())
|
||||
{
|
||||
ScheduleInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureRendererFeatureInstalled();
|
||||
EnsureVolumeOverrideInstalled();
|
||||
}
|
||||
|
||||
private static void EnsureRendererFeatureInstalled()
|
||||
{
|
||||
ScriptableRendererData rendererData = AssetDatabase.LoadAssetAtPath<ScriptableRendererData>(RendererDataPath);
|
||||
if (rendererData == null)
|
||||
return;
|
||||
|
||||
if (!rendererData.TryGetRendererFeature<GlobalGlitchRendererFeature>(out GlobalGlitchRendererFeature feature))
|
||||
{
|
||||
feature = ScriptableObject.CreateInstance<GlobalGlitchRendererFeature>();
|
||||
feature.name = "Global Glitch Renderer Feature";
|
||||
AssetDatabase.AddObjectToAsset(feature, rendererData);
|
||||
rendererData.rendererFeatures.Add(feature);
|
||||
rendererData.SetDirty();
|
||||
EditorUtility.SetDirty(feature);
|
||||
EditorUtility.SetDirty(rendererData);
|
||||
TryValidateRendererFeatures(rendererData);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.ImportAsset(RendererDataPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (feature.renderPassEvent != RenderPassEvent.AfterRenderingPostProcessing)
|
||||
{
|
||||
feature.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing;
|
||||
rendererData.SetDirty();
|
||||
EditorUtility.SetDirty(feature);
|
||||
EditorUtility.SetDirty(rendererData);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureVolumeOverrideInstalled()
|
||||
{
|
||||
VolumeProfile profile = AssetDatabase.LoadAssetAtPath<VolumeProfile>(GameplayVolumeProfilePath);
|
||||
if (profile == null)
|
||||
return;
|
||||
|
||||
RemoveNullVolumeComponents(profile);
|
||||
|
||||
if (profile.TryGet<GlobalGlitchVolume>(out _))
|
||||
return;
|
||||
|
||||
GlobalGlitchVolume component = profile.Add<GlobalGlitchVolume>(true);
|
||||
component.active = false;
|
||||
component.intensity.overrideState = true;
|
||||
component.intensity.value = 0f;
|
||||
component.blockStrength.overrideState = true;
|
||||
component.blockStrength.value = 0.45f;
|
||||
component.colorSplit.overrideState = true;
|
||||
component.colorSplit.value = 0.01f;
|
||||
component.jitterAmount.overrideState = true;
|
||||
component.jitterAmount.value = 0.4f;
|
||||
component.stripFrequency.overrideState = true;
|
||||
component.stripFrequency.value = 48f;
|
||||
component.scanlineStrength.overrideState = true;
|
||||
component.scanlineStrength.value = 0.18f;
|
||||
component.affectSceneView.overrideState = true;
|
||||
component.affectSceneView.value = false;
|
||||
EditorUtility.SetDirty(component);
|
||||
EditorUtility.SetDirty(profile);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
private static void RemoveNullVolumeComponents(VolumeProfile profile)
|
||||
{
|
||||
SerializedObject serializedObject = new SerializedObject(profile);
|
||||
SerializedProperty componentsProperty = serializedObject.FindProperty("components");
|
||||
if (componentsProperty == null || !componentsProperty.isArray)
|
||||
return;
|
||||
|
||||
bool removed = false;
|
||||
for (int i = componentsProperty.arraySize - 1; i >= 0; i--)
|
||||
{
|
||||
SerializedProperty element = componentsProperty.GetArrayElementAtIndex(i);
|
||||
if (element.objectReferenceValue != null)
|
||||
continue;
|
||||
|
||||
componentsProperty.DeleteArrayElementAtIndex(i);
|
||||
removed = true;
|
||||
}
|
||||
|
||||
if (!removed)
|
||||
return;
|
||||
|
||||
serializedObject.ApplyModifiedPropertiesWithoutUndo();
|
||||
EditorUtility.SetDirty(profile);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
private static void TryValidateRendererFeatures(ScriptableRendererData rendererData)
|
||||
{
|
||||
MethodInfo validateMethod = typeof(ScriptableRendererData).GetMethod("ValidateRendererFeatures", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
validateMethod?.Invoke(rendererData, null);
|
||||
}
|
||||
|
||||
private static bool IsUnsafeSelectionActive()
|
||||
{
|
||||
Object activeObject = Selection.activeObject;
|
||||
if (activeObject is VolumeProfile || activeObject is Volume)
|
||||
return true;
|
||||
|
||||
GameObject activeGameObject = Selection.activeGameObject;
|
||||
if (activeGameObject == null)
|
||||
return false;
|
||||
|
||||
return activeGameObject.TryGetComponent<Volume>(out _);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7effde50fff3c34c8c188a696cf3bcf
|
||||
@@ -0,0 +1,157 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class GlobalMonochromeInstaller
|
||||
{
|
||||
private const string RendererDataPath = "Assets/Settings/Renderer2D.asset";
|
||||
private const string GameplayVolumeProfilePath = "Assets/Scenes/gamePlay_gamePlay/gpGV.asset";
|
||||
private static bool installScheduled;
|
||||
|
||||
static GlobalMonochromeInstaller()
|
||||
{
|
||||
ScheduleInstall();
|
||||
}
|
||||
|
||||
[MenuItem("Bansonic/Rendering/Install Global Monochrome")]
|
||||
public static void EnsureInstalledMenu()
|
||||
{
|
||||
EnsureInstalled();
|
||||
}
|
||||
|
||||
private static void ScheduleInstall()
|
||||
{
|
||||
if (installScheduled)
|
||||
return;
|
||||
|
||||
installScheduled = true;
|
||||
EditorApplication.delayCall += RunScheduledInstall;
|
||||
}
|
||||
|
||||
private static void RunScheduledInstall()
|
||||
{
|
||||
installScheduled = false;
|
||||
EnsureInstalled();
|
||||
}
|
||||
|
||||
private static void EnsureInstalled()
|
||||
{
|
||||
if (EditorApplication.isCompiling || BuildPipeline.isBuildingPlayer)
|
||||
{
|
||||
ScheduleInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsUnsafeSelectionActive())
|
||||
{
|
||||
ScheduleInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureRendererFeatureInstalled();
|
||||
EnsureVolumeOverrideInstalled();
|
||||
}
|
||||
|
||||
private static void EnsureRendererFeatureInstalled()
|
||||
{
|
||||
ScriptableRendererData rendererData = AssetDatabase.LoadAssetAtPath<ScriptableRendererData>(RendererDataPath);
|
||||
if (rendererData == null)
|
||||
return;
|
||||
|
||||
if (!rendererData.TryGetRendererFeature<GlobalMonochromeRendererFeature>(out GlobalMonochromeRendererFeature feature))
|
||||
{
|
||||
feature = ScriptableObject.CreateInstance<GlobalMonochromeRendererFeature>();
|
||||
feature.name = "Global Monochrome Renderer Feature";
|
||||
AssetDatabase.AddObjectToAsset(feature, rendererData);
|
||||
rendererData.rendererFeatures.Add(feature);
|
||||
rendererData.SetDirty();
|
||||
EditorUtility.SetDirty(feature);
|
||||
EditorUtility.SetDirty(rendererData);
|
||||
TryValidateRendererFeatures(rendererData);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.ImportAsset(RendererDataPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (feature.renderPassEvent != RenderPassEvent.AfterRenderingPostProcessing)
|
||||
{
|
||||
feature.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing;
|
||||
rendererData.SetDirty();
|
||||
EditorUtility.SetDirty(feature);
|
||||
EditorUtility.SetDirty(rendererData);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureVolumeOverrideInstalled()
|
||||
{
|
||||
VolumeProfile profile = AssetDatabase.LoadAssetAtPath<VolumeProfile>(GameplayVolumeProfilePath);
|
||||
if (profile == null)
|
||||
return;
|
||||
|
||||
RemoveNullVolumeComponents(profile);
|
||||
|
||||
if (profile.TryGet<GlobalMonochromeVolume>(out _))
|
||||
return;
|
||||
|
||||
GlobalMonochromeVolume component = profile.Add<GlobalMonochromeVolume>(true);
|
||||
component.active = false;
|
||||
component.intensity.overrideState = true;
|
||||
component.intensity.value = 0f;
|
||||
component.affectSceneView.overrideState = true;
|
||||
component.affectSceneView.value = false;
|
||||
EditorUtility.SetDirty(component);
|
||||
EditorUtility.SetDirty(profile);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
private static void RemoveNullVolumeComponents(VolumeProfile profile)
|
||||
{
|
||||
SerializedObject serializedObject = new SerializedObject(profile);
|
||||
SerializedProperty componentsProperty = serializedObject.FindProperty("components");
|
||||
if (componentsProperty == null || !componentsProperty.isArray)
|
||||
return;
|
||||
|
||||
bool removed = false;
|
||||
for (int i = componentsProperty.arraySize - 1; i >= 0; i--)
|
||||
{
|
||||
SerializedProperty element = componentsProperty.GetArrayElementAtIndex(i);
|
||||
if (element.objectReferenceValue != null)
|
||||
continue;
|
||||
|
||||
componentsProperty.DeleteArrayElementAtIndex(i);
|
||||
removed = true;
|
||||
}
|
||||
|
||||
if (!removed)
|
||||
return;
|
||||
|
||||
serializedObject.ApplyModifiedPropertiesWithoutUndo();
|
||||
EditorUtility.SetDirty(profile);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
private static void TryValidateRendererFeatures(ScriptableRendererData rendererData)
|
||||
{
|
||||
MethodInfo validateMethod = typeof(ScriptableRendererData).GetMethod("ValidateRendererFeatures", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
validateMethod?.Invoke(rendererData, null);
|
||||
}
|
||||
|
||||
private static bool IsUnsafeSelectionActive()
|
||||
{
|
||||
Object activeObject = Selection.activeObject;
|
||||
if (activeObject is VolumeProfile || activeObject is Volume)
|
||||
return true;
|
||||
|
||||
GameObject activeGameObject = Selection.activeGameObject;
|
||||
if (activeGameObject == null)
|
||||
return false;
|
||||
|
||||
return activeGameObject.TryGetComponent<Volume>(out _);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9530a18d124454244a6fc70d833e3182
|
||||
Reference in New Issue
Block a user