10000 Bugfix/run 2019 by psydack · Pull Request #12 · psydack/uimgui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bugfix/run 2019 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Editor/Editors/UImGuiEditor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ImGuiNET;
using System.Text;
using UImGui.Platform;
using UImGui.Renderer;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -114,6 +115,13 @@ private void CheckRequirements()
_messages.AppendLine("Must assign a RenderFeature when using the URP.");
}

#if !UNITY_2020_1_OR_NEWER
if ((RenderType)_renderer.enumValueIndex == RenderType.Mesh)
{
_messages.AppendLine("Use procedural.");
}
#endif

SerializedProperty configFlags = _initialConfiguration.FindPropertyRelative("ImGuiConfig");
if (!PlatformUtility.IsAvailable((InputType)_platform.enumValueIndex))
{
Expand Down
1 change: 1 addition & 0 deletions Resources/Shaders/PassesUniversal.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef UNITY_COLORSPACE_GAMMA
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#endif

#include "./Common.hlsl"

TEXTURE2D(_Texture);
Expand Down
6 changes: 4 additions & 2 deletions Source/Renderer/RendererMesh.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ImGuiNET;
#if UNITY_2020_1_OR_NEWER
using ImGuiNET;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -222,4 +223,5 @@ private void CreateDrawCommands(CommandBuffer commandBuffer, ImDrawDataPtr drawD
commandBuffer.DisableScissorRect();
}
}
}
}
#endif
19 changes: 11 additions & 8 deletions Source/Renderer/RendererProcedural.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ internal sealed class RendererProcedural : IRenderer
private readonly TextureManager _textureManager;

private readonly MaterialPropertyBlock _materialProperties = new MaterialPropertyBlock();
private readonly int[] _drawArgs = new int[] { 0, 1, 0, 0, 0 }; // Used to build argument buffer.

private Material _material;

Expand Down Expand Up @@ -171,14 +170,18 @@ private unsafe void UpdateBuffers(ImDrawDataPtr drawData)
_indexBuffer.SetData(idxArray, 0, idxOf, idxArray.Length);

// Arguments for indexed draw.
_drawArgs[3] = vtxOf; // Base vertex location.
for (int i = 0, iMax = drawList.CmdBuffer.Size; i < iMax; ++i)
for (int meshIndex = 0, iMax = drawList.CmdBuffer.Size; meshIndex < iMax; ++meshIndex)
{
ImDrawCmdPtr cmd = drawList.CmdBuffer[i];
_drawArgs[0] = (int)cmd.ElemCount; // Index count per instance.
_drawArgs[2] = idxOf + (int)cmd.IdxOffset; // Start index location.
_argumentsBuffer.SetData(_drawArgs, 0, argOf, 5);

ImDrawCmdPtr cmd = drawList.CmdBuffer[meshIndex];
var drawArgs = new int[]
{
(int)cmd.ElemCount,
1,
idxOf + (int)cmd.IdxOffset,
vtxOf,
0
};
_argumentsBuffer.SetData(drawArgs, 0, argOf, 5);
argOf += 5; // 5 int for each command.
}
vtxOf += vtxArray.Length;
Expand Down
2 changes: 2 additions & 0 deletions Source/Utils/RenderUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public static IRenderer Create(RenderType type, ShaderResourcesAsset shaders, Te

switch (type)
{
#if UNITY_2020_1_OR_NEWER
case RenderType.Mesh:
return new RendererMesh(shaders, textures);
#endif
case RenderType.Procedural:
return new RendererProcedural(shaders, textures);
default:
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"displayName": "UImGui",
"version": "4.0.0",
"description": "A Unity wrapper for ImGui",
"unity": "2020.3",
"unity": "2019.4",
"dependencies": {
"com.unity.collections": "0.15.0-preview.21"
},
"keywords": [
"dear",
Expand Down
0