Skip to content

Instantly share code, notes, and snippets.

@psuong
Created February 9, 2023 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psuong/72c3c4afe3bb6ac5b18d52b91b44f2f7 to your computer and use it in GitHub Desktop.
Save psuong/72c3c4afe3bb6ac5b18d52b91b44f2f7 to your computer and use it in GitHub Desktop.
using InitialPrefabs.NimGui.Loop;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Rendering;
namespace InitialPrefabs.NimGui.Render {
public class ImGuiHDRPRenderPass : CustomPass {
/// <summary>
/// In HDRP this is aliased to an automatically initialized CommandBuffer in <see cref="CommandBuffer"/>
/// and <see cref="DefaultImGuiInitializationProxy.OnEnable"/>
/// </summary>
public CommandBuffer DrawCommand { get; private set; }
/// <summary>
/// In HDRP this is aliased to an automatically initialized ProperyBlock in <see cref="ImGuiRunner.CommandBuffer"/>
/// and <see cref="DefaultImGuiInitializationProxy.OnEnable"/>
/// </summary>
public MaterialPropertyBlock PropertyBlock { get; private set; }
protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd) {
// Setup code here
DrawCommand = ImGuiRunner.CommandBuffer;
PropertyBlock = ImGuiRunner.PropertyBlock;
}
protected override void Execute(CustomPassContext ctx) {
#if UNITY_EDITOR
// TODO: Figure out how to grab whether the camera is a scene camera or preview camera.
#endif
var renderContext = ctx.renderContext;
renderContext.ExecuteCommandBuffer(DrawCommand);
}
protected override void Cleanup() {
// Cleanup code
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment