store overlay scene as node instead of packedscene

This commit is contained in:
Crispy 2021-07-06 22:38:12 +02:00
parent bf3908de5c
commit 5fc14a3def
3 changed files with 9 additions and 12 deletions

View file

@ -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 )]

View file

@ -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")

View file

@ -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",