Hello,
I was unable to find any API for obtaining the list of RenderFeatures curently added to the active RendererData. I found some posts regarding using reflection to do the job, however.
Is that still the only option for getting the RenderFeatures at runtime?
My current code is following:
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static List<ScriptableRendererFeature> GetRendererFeatures(int rendererIndex = 0)
{
// Get desired pipeline asset
var renderer = (GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset)?.GetRenderer(rendererIndex);
// Get the rendererFeatures property
var property = typeof(ScriptableRenderer).GetProperty("rendererFeatures", BindingFlags.NonPublic | BindingFlags.Instance);
// Return the list of ScriptableFeatures
return property?.GetValue(renderer) as List<ScriptableRendererFeature>;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T GetRenderFeatureInstance<T> (List<ScriptableRendererFeature> featureList) where T : ScriptableRendererFeature
{
if (featureList == null)
return null;
foreach (var feature in featureList)
{
if (feature is T desiredFeature)
{
return desiredFeature;
}
}
return null;
}