Singularity/Library/PackageCache/com.unity.render-pipelines..../Editor/Converter/PPv2/EffectConverters/PostProcessEffectSettingsCo...
2024-05-06 11:45:45 -07:00

44 lines
1.5 KiB
C#

#if PPV2_EXISTS
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal.Converters
{
public abstract class PostProcessEffectSettingsConverter : ScriptableObject
{
protected abstract Type OldSettingsType { get; }
public void AddConvertedProfileSettingsToProfile(
BIRPRendering.PostProcessEffectSettings oldSettings,
VolumeProfile targetProfile)
{
if (oldSettings == null || oldSettings.GetType() != OldSettingsType) return;
if (targetProfile == null || targetProfile.Has(OldSettingsType)) return;
ConvertToTarget(oldSettings, targetProfile);
}
protected abstract void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldBloom,
VolumeProfile targetProfile);
protected T AddVolumeComponentToAsset<T>(VolumeProfile targetProfileAsset) where T : VolumeComponent
{
if (!targetProfileAsset) return null;
var profilePath = AssetDatabase.GetAssetPath(targetProfileAsset);
if (string.IsNullOrEmpty(profilePath)) return null;
var newVolumeComponent = targetProfileAsset.Add<T>();
AssetDatabase.AddObjectToAsset(newVolumeComponent, targetProfileAsset);
return newVolumeComponent;
}
}
}
#endif