From 5fc14a3defd66c730eaf68186257f7f3aed78163 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Tue, 6 Jul 2021 22:38:12 +0200 Subject: [PATCH] store overlay scene as node instead of packedscene --- ovr-utils/OverlayManager.tscn | 4 +--- .../addons/openvr_overlay/overlay_instance.gd | 15 +++++++-------- ovr-utils/settings_definition.gd | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ovr-utils/OverlayManager.tscn b/ovr-utils/OverlayManager.tscn index e6583e6..925ea82 100644 --- a/ovr-utils/OverlayManager.tscn +++ b/ovr-utils/OverlayManager.tscn @@ -1,6 +1,5 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=4 format=2] -[ext_resource path="res://special_overlays/MainOverlay.tscn" type="PackedScene" id=1] [ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=2] [ext_resource path="res://OverlaySettingsSync.tscn" type="PackedScene" id=3] [ext_resource path="res://overlay_manager.gd" type="Script" id=4] @@ -9,7 +8,6 @@ script = ExtResource( 4 ) [node name="MainOverlay" parent="." instance=ExtResource( 2 )] -overlay_scene = ExtResource( 1 ) add_cursor = true [node name="OverlaySettingsSync" parent="MainOverlay" instance=ExtResource( 3 )] diff --git a/ovr-utils/addons/openvr_overlay/overlay_instance.gd b/ovr-utils/addons/openvr_overlay/overlay_instance.gd index 52559d3..2da2249 100644 --- a/ovr-utils/addons/openvr_overlay/overlay_instance.gd +++ b/ovr-utils/addons/openvr_overlay/overlay_instance.gd @@ -11,7 +11,6 @@ signal offset_changed const TARGETS = ["head", "left", "right", "world"] export (String, "head", "left", "right", "world") var target = "left" setget set_target -export var overlay_scene: PackedScene export var width_meters := 0.4 setget set_width_in_meters export var alpha := 1.0 setget set_alpha export var add_grabbing := true # add grabbing module @@ -34,6 +33,7 @@ var path := "res://special_overlays/MainOverlay.tscn" setget set_path var path_invalid := false onready var container = $OverlayViewport/Container +var overlay_scene: Node func _ready() -> void: @@ -53,9 +53,6 @@ func _ready() -> void: if add_grabbing: add_grab() - if overlay_scene: - container.add_child(overlay_scene.instance()) - update_tracker_id() call_deferred("update_offset") @@ -152,14 +149,16 @@ func set_path(new: String) -> void: path = new path_invalid = false - overlay_scene = load(path) - if not overlay_scene: + var packed_overlay = load(path) + if not packed_overlay: path_invalid = true - overlay_scene = load("res://special_overlays/UnknownType.tscn") + overlay_scene = load("res://special_overlays/UnknownType.tscn").instance() + else: + overlay_scene = packed_overlay.instance() if container.get_child_count() > 0: container.get_child(0).queue_free() - container.add_child(overlay_scene.instance()) + container.add_child(overlay_scene) emit_signal("path_changed") diff --git a/ovr-utils/settings_definition.gd b/ovr-utils/settings_definition.gd index 1df50a0..0924ae0 100644 --- a/ovr-utils/settings_definition.gd +++ b/ovr-utils/settings_definition.gd @@ -1,6 +1,6 @@ extends Node -const PATH = "user://overlay_data_DEV.json" +const PATH = "user://overlay_data.json" const DEF = { "grab_mode": { "name": "Grab mode",