Skip to content

Commit

Permalink
feat: add a lot of functionality
Browse files Browse the repository at this point in the history
* add todo comment
* add input type property
* add render type  property
* add uioconfig default values
* add shader resource property
* remove return inside fail methods
* reorder methods for obvious steps
  • Loading branch information
Rofli Sanches committed May 14, 2021
1 parent 5092a29 commit 848cbe2
Showing 1 changed file with 57 additions and 21 deletions.
78 changes: 57 additions & 21 deletions Source/UImGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace UImGui
{

// TODO: Check Multithread run.
public class UImGui : MonoBehaviour
{
private Context _context;
Expand All @@ -23,26 +23,58 @@ public class UImGui : MonoBehaviour
private Camera _camera = null;

[SerializeField]
private RenderUImGui _renderFeature = null;
private RenderImGui _renderFeature = null;

//[SerializeField] private RenderUtils.RenderType _rendererType = RenderUtils.RenderType.Mesh;
//[SerializeField] private Platform.Type _platformType = Platform.Type.InputManager;
[SerializeField]
private RenderType _rendererType = RenderType.Mesh;

[SerializeField]
private InputType _platformType = InputType.InputManager;

[Tooltip("Null value uses default imgui.ini file.")]
[SerializeField]
private IniSettingsAsset _iniSettings = null;

[Header("Configuration")]

[SerializeField]
private IOConfig _initialConfiguration = default;
//[SerializeField] private FontAtlasConfigAsset _fontAtlasConfiguration = null;
//[SerializeField] private IniSettingsAsset _iniSettings = null; // null: uses default imgui.ini file
private UIOConfig _initialConfiguration = new UIOConfig
{
ImGuiConfig = ImGuiConfigFlags.DockingEnable | ImGuiConfigFlags.NavEnableKeyboard,

DoubleClickTime = 0.30f,
DoubleClickMaxDist = 6.0f,

DragThreshold = 6.0f,

KeyRepeatDelay = 0.250f,
KeyRepeatRate = 0.050f,

FontGlobalScale = 1.0f,
FontAllowUserScaling = false,

DisplayFramebufferScale = Vector2.one,

MouseDrawCursor = false,
TextCursorBlink = false,

ResizeFromEdges = true,
MoveFromTitleOnly = true,
ConfigMemoryCompactTimer = 1f,
};

[SerializeField]
private FontAtlasConfigAsset _fontAtlasConfiguration = null;

[Header("Customization")]
//[SerializeField] private ShaderResourcesAsset _shaders = null;
[SerializeField]
private ShaderResourcesAsset _shaders = null;

[SerializeField]
private StyleAsset _style = null;
//[SerializeField] private CursorShapesAsset _cursorShapes = null;
//private static readonly ProfilerMarker s_prepareFramePerfMarker = new ProfilerMarker("DearImGui.PrepareFrame");
//private static readonly ProfilerMarker s_layoutPerfMarker = new ProfilerMarker("DearImGui.Layout");
//private static readonly ProfilerMarker s_drawListPerfMarker = new ProfilerMarker("DearImGui.RenderDrawLists");

[SerializeField]
private CursorShapesAsset _cursorShapes = null;

private void Awake()
{
Expand All @@ -56,18 +88,21 @@ private void OnDestroy()

private void OnEnable()
{
_usingURP = RenderUtils.IsUsingURP();
void Fail(string reason)
{
enabled = false;
throw new System.Exception($"Failed to start: {reason}");
}

if (_camera == null)
{
Fail(nameof(_camera));
return;
}

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

_renderCommandBuffer = RenderUtils.GetCommandBuffer("UImGui");
Expand All @@ -92,14 +127,15 @@ private void OnEnable()
//_context.textures.Initialize(io);

//SetPlatform(Platform.Create(_platformType, _cursorShapes, _iniSettings), io);
//SetRenderer(RenderUtils.Create(_rendererType, _shaders, _context.textures), io);
//if (_platform == null) Fail(nameof(_platform));
//if (_renderer == null) Fail(nameof(_renderer));
if (_platform == null)
{
Fail(nameof(_platform));
}

void Fail(string reason)
//SetRenderer(RenderUtils.Create(_rendererType, _shaders, _context.textures), io);
if (_renderer == null)
{
enabled = false;
throw new System.Exception($"Failed to start: {reason}");
Fail(nameof(_renderer));
}
}

Expand Down

0 comments on commit 848cbe2

Please sign in to comment.