holopy3/Assets/Klak/Spout/Runtime/Internal/Utility.cs

39 lines
969 B
C#
Raw Normal View History

2020-12-10 14:25:12 +00:00
// KlakSpout - Spout video frame sharing plugin for Unity
// https://github.com/keijiro/KlakSpout
using UnityEngine;
using UnityEngine.Rendering;
namespace Klak.Spout
{
// Internal utilities
static class Util
{
internal static void Destroy(Object obj)
{
if (obj == null) return;
if (Application.isPlaying)
Object.Destroy(obj);
else
Object.DestroyImmediate(obj);
}
static CommandBuffer _commandBuffer;
internal static void
IssuePluginEvent(PluginEntry.Event pluginEvent, System.IntPtr ptr)
{
if (_commandBuffer == null) _commandBuffer = new CommandBuffer();
_commandBuffer.IssuePluginEventAndData(
PluginEntry.GetRenderEventFunc(), (int)pluginEvent, ptr
);
Graphics.ExecuteCommandBuffer(_commandBuffer);
_commandBuffer.Clear();
}
}
}