Gizmos - simple line connecting the portals
This commit is contained in:
parent
2da0429cdd
commit
eeb35efa18
42
addons/portal_gizmos/gizmo.gd
Normal file
42
addons/portal_gizmos/gizmo.gd
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
extends EditorNode3DGizmoPlugin
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
print("[gizmo] _init")
|
||||||
|
create_material("main", Color(1,0,1), false, true, false)
|
||||||
|
|
||||||
|
|
||||||
|
func _get_gizmo_name() -> String:
|
||||||
|
return "PortalGizmo"
|
||||||
|
|
||||||
|
|
||||||
|
func _has_gizmo(for_node_3d: Node3D) -> bool:
|
||||||
|
var result: bool = for_node_3d is Portal
|
||||||
|
if result: print("[gizmo] _has_gizmo: " + for_node_3d.name)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
func _redraw(gizmo):
|
||||||
|
var node3d = gizmo.get_node_3d() as Portal
|
||||||
|
print("[gizmo] _redraw: " + node3d.name)
|
||||||
|
|
||||||
|
gizmo.clear() # Always clear the gizmo
|
||||||
|
|
||||||
|
if node3d not in EditorInterface.get_selection().get_selected_nodes():
|
||||||
|
return # If not selected, don't draw anything
|
||||||
|
|
||||||
|
|
||||||
|
var lines = PackedVector3Array()
|
||||||
|
|
||||||
|
lines.push_back(Vector3(0, 0, 0))
|
||||||
|
|
||||||
|
if node3d.exit_portal != null:
|
||||||
|
lines.push_back(node3d.to_local(node3d.exit_portal.global_position))
|
||||||
|
else:
|
||||||
|
lines.push_back(Vector3(5, 5, 5))
|
||||||
|
|
||||||
|
#var handles = PackedVector3Array()
|
||||||
|
#handles.push_back(Vector3(0, 1, 0))
|
||||||
|
#handles.push_back(Vector3(0, 2, 0))
|
||||||
|
|
||||||
|
gizmo.add_lines(lines, get_material("main", gizmo), false)
|
||||||
|
#gizmo.add_handles(handles, get_material("handles", gizmo), [])
|
1
addons/portal_gizmos/gizmo.gd.uid
Normal file
1
addons/portal_gizmos/gizmo.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://b8vlwx31bxx4b
|
7
addons/portal_gizmos/plugin.cfg
Normal file
7
addons/portal_gizmos/plugin.cfg
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[plugin]
|
||||||
|
|
||||||
|
name="Portal Gizmos"
|
||||||
|
description="Plugin providing 3D Gizmos for portals"
|
||||||
|
author="Vojtech Struhar"
|
||||||
|
version="0.1"
|
||||||
|
script="portal_gizmos.gd"
|
13
addons/portal_gizmos/portal_gizmos.gd
Normal file
13
addons/portal_gizmos/portal_gizmos.gd
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
@tool
|
||||||
|
extends EditorPlugin
|
||||||
|
|
||||||
|
const GIZMO_PACKED = preload("gizmo.gd")
|
||||||
|
var gizmo = GIZMO_PACKED.new()
|
||||||
|
|
||||||
|
func _enter_tree() -> void:
|
||||||
|
print("[portal_gizmos] Enter")
|
||||||
|
add_node_3d_gizmo_plugin(gizmo)
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
print("[portal_gizmos] Exit")
|
||||||
|
remove_node_3d_gizmo_plugin(gizmo)
|
1
addons/portal_gizmos/portal_gizmos.gd.uid
Normal file
1
addons/portal_gizmos/portal_gizmos.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://c61kmx68labq0
|
@ -20,6 +20,10 @@ config/icon="res://icon.svg"
|
|||||||
window/size/viewport_width=1920
|
window/size/viewport_width=1920
|
||||||
window/size/viewport_height=1080
|
window/size/viewport_height=1080
|
||||||
|
|
||||||
|
[editor_plugins]
|
||||||
|
|
||||||
|
enabled=PackedStringArray("res://addons/portal_gizmos/plugin.cfg")
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
move_left={
|
move_left={
|
||||||
|
Loading…
Reference in New Issue
Block a user