using System;
using System.Collections.Generic;
namespace UnityEngine.Rendering
{
///
/// Bridge class for camera captures.
///
public static class CameraCaptureBridge
{
private static Dictionary>> actionDict =
new Dictionary>>();
private static bool _enabled;
///
/// Enable camera capture.
///
public static bool enabled
{
get
{
return _enabled;
}
set
{
_enabled = value;
}
}
///
/// Provides the set actions to the renderer to be triggered at the end of the render loop for camera capture
///
/// The camera to get actions for
/// Enumeration of actions
public static IEnumerator> GetCaptureActions(Camera camera)
{
if (!actionDict.TryGetValue(camera, out var actions) || actions.Count == 0)
return null;
return actions.GetEnumerator();
}
///
/// Adds actions for camera capture
///
/// The camera to add actions for
/// The action to add
public static void AddCaptureAction(Camera camera, Action action)
{
actionDict.TryGetValue(camera, out var actions);
if (actions == null)
{
actions = new HashSet>();
actionDict.Add(camera, actions);
}
actions.Add(action);
}
///
/// Removes actions for camera capture
///
/// The camera to remove actions for
/// The action to remove
public static void RemoveCaptureAction(Camera camera, Action action)
{
if (camera == null)
return;
if (actionDict.TryGetValue(camera, out var actions))
actions.Remove(action);
}
}
}