-
Notifications
You must be signed in to change notification settings - Fork 1
/
imguiviewporttest.cs
71 lines (57 loc) · 1.68 KB
/
imguiviewporttest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using Godot;
using System;
using ImGuiNET;
using Vector2 = System.Numerics.Vector2;
using Chisel;
public class imguiviewporttest : Control
{
public Boolean show = true;
public override void _Ready()
{
}
public override void _Process(float delta)
{
}
public override void _Input(InputEvent @event)
{
if (@event is InputEventMouse)
{
InputEvent MouseEvent = (InputEvent)@event.Duplicate();
MouseEvent.Set("position", GetGlobalTransform().XformInv((Godot.Vector2)@event.Get("global_position")));
GetNode<Viewport>("ViewportContainer/Viewport").UnhandledInput(MouseEvent);
}
else
{
GetNode<Viewport>("ViewportContainer/Viewport").UnhandledInput(@event);
}
}
private void _on_ImGuiNode_IGLayout()
{
if (show == false)
{
return;
}
ImGui.Begin("Viewport Test", ref show, ImGuiWindowFlags.None);
InputHandler();
Texture Tex = GetNode<Viewport>("ViewportContainer/Viewport").GetTexture();
IntPtr TexId = ImGuiGD.BindTexture(Tex);
ImGui.Image(TexId, new Vector2(Tex.GetWidth(), Tex.GetHeight()));
ImGui.SetWindowSize(new Vector2(Tex.GetWidth(), Tex.GetHeight()));
ImGui.End();
}
private void InputHandler()
{
if (ImGui.IsMouseDown(ImGuiMouseButton.Right))
{
Globals.CameraOn = true;
}
else
{
Globals.CameraOn = false;
}
if (ImGui.IsWindowHovered())
Globals.In3DView = true;
else
Globals.In3DView = false;
}
}