Skip to content

Commit

Permalink
feat: add hd support
Browse files Browse the repository at this point in the history
  • Loading branch information
Rofli Sanches committed May 26, 2021
1 parent f60a221 commit 3829471
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 8 additions & 6 deletions Source/UImGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using UImGui.Renderer;
using UnityEngine;
using UnityEngine.Rendering;
#if HAS_HDRP
#endif

namespace UImGui
{
Expand All @@ -14,7 +16,6 @@ public class UImGui : MonoBehaviour
private IRenderer _renderer;
private IPlatform _platform;
private CommandBuffer _renderCommandBuffer;
private bool _usingURP;

[SerializeField]
private Camera _camera = null;
Expand Down Expand Up @@ -76,6 +77,8 @@ public class UImGui : MonoBehaviour
[SerializeField]
private bool _doGlobalLayout = true; // Do global/default Layout event too.

public CommandBuffer CommandBuffer => _renderCommandBuffer;

public event System.Action Layout; // Layout event for *this* ImGui instance.

public void Reload()
Expand Down Expand Up @@ -107,19 +110,18 @@ void Fail(string reason)
Fail(nameof(_camera));
}

_usingURP = RenderUtility.IsUsingURP();
if (_renderFeature == null && _usingURP)
if (_renderFeature == null && RenderUtility.IsUsingURP())
{
Fail(nameof(_renderFeature));
}

_renderCommandBuffer = RenderUtility.GetCommandBuffer(Constants.UImGuiCommandBuffer);

if (_usingURP)
if (RenderUtility.IsUsingURP())
{
_renderFeature.CommandBuffer = _renderCommandBuffer;
}
else
else if (!RenderUtility.IsUsingHDRP())
{
_camera.AddCommandBuffer(CameraEvent.AfterEverything, _renderCommandBuffer);
}
Expand Down Expand Up @@ -161,7 +163,7 @@ private void OnDisable()
_context.TextureManager.Shutdown();
_context.TextureManager.DestroyFontAtlas(io);

if (_usingURP)
if (RenderUtility.IsUsingURP())
{
if (_renderFeature != null)
{
Expand Down
7 changes: 6 additions & 1 deletion UImGui.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"references": [
"GUID:df380645f10b7bc4b97d4f5eb6303d95",
"GUID:15fc0a57446b3144c949da3e2b9737a9",
"GUID:ade3d29ceff033c419baa91387fb70d3",
"GUID:457756d89b35d2941b3e7b37b4ece6f1",
"GUID:e0cd26848372d4e5c891c569017e11f1",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:6fc336898376f124f8e803ade069c103"
Expand All @@ -17,6 +17,11 @@
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [
{
"name": "com.unity.render-pipelines.high-definition",
"expression": "10",
"define": "HAS_HDRP"
},
{
"name": "com.unity.render-pipelines.universal",
"expression": "10",
Expand Down

0 comments on commit 3829471

Please sign in to comment.