-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
612 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# PCK loading demo | ||
|
||
This demo shows how you can load and unload exported PCK files at runtime. | ||
|
||
Language: GDScript | ||
|
||
Renderer: GLES 2 | ||
|
||
## Sub-projects | ||
|
||
There are three Godot projects under `sub_projects`. All have been exported to their respective PCK files and are loaded by the main project. | ||
|
||
## Screenshots | ||
|
||
![Screenshot](screenshots/screenshot.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
extends Control | ||
|
||
@onready var vp_orig = $HBoxContainer/VBoxContainer/SubViewportContainer/ViewOrig | ||
@onready var vp_a = $HBoxContainer/VBoxContainer2/SubViewportContainer/ViewA | ||
@onready var vp_b = $HBoxContainer/VBoxContainer3/SubViewportContainer/ViewB | ||
@onready var no_scene_lbl = $NoNodeLbl | ||
|
||
@export_file("*.pck") var pck_1 | ||
@export_file("*.pck") var pck_2 | ||
@export_file("*.pck") var pck_3 | ||
|
||
|
||
func _ready(): | ||
reload_scene() | ||
|
||
|
||
func reload_scene(): | ||
$LineEdit.text = "" | ||
populate_file_list("res://") | ||
|
||
load_scene_at_node("res://orig.tscn", vp_orig) | ||
load_scene_at_node("res://a.tscn", vp_a) | ||
load_scene_at_node("res://b.tscn", vp_b) | ||
|
||
|
||
func populate_file_list(path: String): | ||
var dir = Directory.new() | ||
dir.open(path) | ||
dir.list_dir_begin() | ||
var file_name = dir.get_next() | ||
while file_name != "": | ||
if dir.current_is_dir(): | ||
populate_file_list(path + file_name + "/") | ||
else: | ||
$LineEdit.text += path + file_name + '\n' | ||
file_name = dir.get_next() | ||
|
||
|
||
func load_scene_at_node(scene_name: String, node: Node): | ||
var child | ||
if ResourceLoader.exists(scene_name): | ||
child = load(scene_name).instantiate() | ||
else: | ||
child = no_scene_lbl.duplicate() | ||
child.position = Vector2.ZERO | ||
if node.get_child_count() > 0: | ||
node.remove_child(node.get_child(0)) | ||
node.add_child(child) | ||
|
||
|
||
func _on_load1_pressed(): | ||
ProjectSettings.load_resource_pack(pck_1, $VBoxContainer/HBoxContainer/CheckBox.is_pressed()) | ||
reload_scene() | ||
|
||
|
||
func _on_unload1_pressed(): | ||
ProjectSettings.unload_resource_pack(pck_1) | ||
reload_scene() | ||
|
||
|
||
func _on_load2_pressed(): | ||
ProjectSettings.load_resource_pack(pck_2, $VBoxContainer/HBoxContainer2/CheckBox.is_pressed()) | ||
reload_scene() | ||
|
||
|
||
func _on_unload2_pressed(): | ||
ProjectSettings.unload_resource_pack(pck_2) | ||
reload_scene() | ||
|
||
|
||
func _on_load3_pressed(): | ||
ProjectSettings.load_resource_pack(pck_3, $VBoxContainer/HBoxContainer3/CheckBox.is_pressed()) | ||
reload_scene() | ||
|
||
|
||
func _on_unload3_pressed(): | ||
ProjectSettings.unload_resource_pack(pck_3) | ||
reload_scene() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://btpbmejdh00qx" | ||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://icon.png" | ||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://biqc8303kctlu"] | ||
|
||
[ext_resource type="Script" path="res://Root.gd" id="1_dd1mq"] | ||
|
||
[node name="Root" type="Control"] | ||
script = ExtResource( "1_dd1mq" ) | ||
pck_1 = "res://sub_projects/1.pck" | ||
pck_2 = "res://sub_projects/2.pck" | ||
pck_3 = "res://sub_projects/3.pck" | ||
|
||
[node name="LineEdit" type="Label" parent="."] | ||
offset_left = 67.0 | ||
offset_top = 75.0 | ||
offset_right = 463.0 | ||
offset_bottom = 375.0 | ||
autowrap_mode = 1 | ||
clip_text = true | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="."] | ||
offset_left = 552.0 | ||
offset_top = 81.0 | ||
offset_right = 932.0 | ||
offset_bottom = 379.0 | ||
theme_override_constants/separation = 20 | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] | ||
offset_right = 380.0 | ||
offset_bottom = 86.0 | ||
size_flags_vertical = 3 | ||
theme_override_constants/separation = 20 | ||
|
||
[node name="Load" type="Button" parent="VBoxContainer/HBoxContainer"] | ||
offset_right = 125.0 | ||
offset_bottom = 86.0 | ||
size_flags_horizontal = 3 | ||
text = "Load 1.pck" | ||
|
||
[node name="Unload" type="Button" parent="VBoxContainer/HBoxContainer"] | ||
offset_left = 145.0 | ||
offset_right = 271.0 | ||
offset_bottom = 86.0 | ||
size_flags_horizontal = 3 | ||
text = "Unload 1.pck" | ||
|
||
[node name="CheckBox" type="CheckBox" parent="VBoxContainer/HBoxContainer"] | ||
offset_left = 291.0 | ||
offset_right = 380.0 | ||
offset_bottom = 86.0 | ||
text = "Replace | ||
files?" | ||
|
||
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"] | ||
offset_top = 106.0 | ||
offset_right = 380.0 | ||
offset_bottom = 192.0 | ||
size_flags_vertical = 3 | ||
theme_override_constants/separation = 20 | ||
|
||
[node name="Load" type="Button" parent="VBoxContainer/HBoxContainer2"] | ||
offset_right = 125.0 | ||
offset_bottom = 86.0 | ||
size_flags_horizontal = 3 | ||
text = "Load 2.pck" | ||
|
||
[node name="Unload" type="Button" parent="VBoxContainer/HBoxContainer2"] | ||
offset_left = 145.0 | ||
offset_right = 271.0 | ||
offset_bottom = 86.0 | ||
size_flags_horizontal = 3 | ||
text = "Unload 2.pck" | ||
|
||
[node name="CheckBox" type="CheckBox" parent="VBoxContainer/HBoxContainer2"] | ||
offset_left = 291.0 | ||
offset_right = 380.0 | ||
offset_bottom = 86.0 | ||
text = "Replace | ||
files?" | ||
|
||
[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"] | ||
offset_top = 212.0 | ||
offset_right = 380.0 | ||
offset_bottom = 298.0 | ||
size_flags_vertical = 3 | ||
theme_override_constants/separation = 20 | ||
|
||
[node name="Load" type="Button" parent="VBoxContainer/HBoxContainer3"] | ||
offset_right = 125.0 | ||
offset_bottom = 86.0 | ||
size_flags_horizontal = 3 | ||
text = "Load 3.pck" | ||
|
||
[node name="Unload" type="Button" parent="VBoxContainer/HBoxContainer3"] | ||
offset_left = 145.0 | ||
offset_right = 271.0 | ||
offset_bottom = 86.0 | ||
size_flags_horizontal = 3 | ||
text = "Unload 3.pck" | ||
|
||
[node name="CheckBox" type="CheckBox" parent="VBoxContainer/HBoxContainer3"] | ||
offset_left = 291.0 | ||
offset_right = 380.0 | ||
offset_bottom = 86.0 | ||
text = "Replace | ||
files?" | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="."] | ||
offset_left = 44.0 | ||
offset_top = 415.0 | ||
offset_right = 934.0 | ||
offset_bottom = 569.0 | ||
size_flags_horizontal = 3 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"] | ||
offset_right = 294.0 | ||
offset_bottom = 158.0 | ||
size_flags_horizontal = 3 | ||
|
||
[node name="Label" type="Label" parent="HBoxContainer/VBoxContainer"] | ||
offset_right = 294.0 | ||
offset_bottom = 26.0 | ||
text = "orig.tscn" | ||
|
||
[node name="SubViewportContainer" type="SubViewportContainer" parent="HBoxContainer/VBoxContainer"] | ||
minimum_size = Vector2(256, 0) | ||
offset_top = 30.0 | ||
offset_right = 294.0 | ||
offset_bottom = 158.0 | ||
size_flags_vertical = 3 | ||
|
||
[node name="ViewOrig" type="SubViewport" parent="HBoxContainer/VBoxContainer/SubViewportContainer"] | ||
handle_input_locally = false | ||
size = Vector2i(256, 128) | ||
render_target_update_mode = 4 | ||
|
||
[node name="VBoxContainer2" type="VBoxContainer" parent="HBoxContainer"] | ||
offset_left = 298.0 | ||
offset_right = 592.0 | ||
offset_bottom = 158.0 | ||
size_flags_horizontal = 3 | ||
|
||
[node name="Label" type="Label" parent="HBoxContainer/VBoxContainer2"] | ||
offset_right = 294.0 | ||
offset_bottom = 26.0 | ||
text = "a.tscn" | ||
|
||
[node name="SubViewportContainer" type="SubViewportContainer" parent="HBoxContainer/VBoxContainer2"] | ||
minimum_size = Vector2(256, 0) | ||
offset_top = 30.0 | ||
offset_right = 294.0 | ||
offset_bottom = 158.0 | ||
size_flags_vertical = 3 | ||
|
||
[node name="ViewA" type="SubViewport" parent="HBoxContainer/VBoxContainer2/SubViewportContainer"] | ||
handle_input_locally = false | ||
size = Vector2i(256, 128) | ||
render_target_update_mode = 4 | ||
|
||
[node name="VBoxContainer3" type="VBoxContainer" parent="HBoxContainer"] | ||
offset_left = 596.0 | ||
offset_right = 890.0 | ||
offset_bottom = 158.0 | ||
size_flags_horizontal = 3 | ||
|
||
[node name="Label" type="Label" parent="HBoxContainer/VBoxContainer3"] | ||
offset_right = 294.0 | ||
offset_bottom = 26.0 | ||
text = "b.tscn" | ||
|
||
[node name="SubViewportContainer" type="SubViewportContainer" parent="HBoxContainer/VBoxContainer3"] | ||
minimum_size = Vector2(256, 0) | ||
offset_top = 30.0 | ||
offset_right = 294.0 | ||
offset_bottom = 158.0 | ||
size_flags_vertical = 3 | ||
|
||
[node name="ViewB" type="SubViewport" parent="HBoxContainer/VBoxContainer3/SubViewportContainer"] | ||
handle_input_locally = false | ||
size = Vector2i(256, 128) | ||
render_target_update_mode = 4 | ||
|
||
[node name="NoNodeLbl" type="Label" parent="."] | ||
offset_left = -184.0 | ||
offset_top = -133.0 | ||
offset_right = -144.0 | ||
offset_bottom = -110.0 | ||
text = "Missing scene file!" | ||
|
||
[node name="Label" type="Label" parent="."] | ||
offset_left = 65.0 | ||
offset_top = 49.0 | ||
offset_right = 128.0 | ||
offset_bottom = 75.0 | ||
text = "File List:" | ||
|
||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Load" to="." method="_on_load1_pressed"] | ||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Unload" to="." method="_on_unload1_pressed"] | ||
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/Load" to="." method="_on_load2_pressed"] | ||
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/Unload" to="." method="_on_unload2_pressed"] | ||
[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Load" to="." method="_on_load3_pressed"] | ||
[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Unload" to="." method="_on_unload3_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[gd_scene format=3 uid="uid://dr3ofl6lrt7v2"] | ||
|
||
[node name="Control" type="Control"] | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
|
||
[node name="Label" type="Label" parent="."] | ||
offset_right = 306.0 | ||
offset_bottom = 104.0 | ||
text = "Greetings from original data.pck | ||
file! This should always be here; | ||
if somehow this scene fails to | ||
load, something messed up | ||
`res://` lookup!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
; Engine configuration file. | ||
; It's best edited using the editor UI and not directly, | ||
; since the parameters that go here are not all obvious. | ||
; | ||
; Format: | ||
; [section] ; section goes between [] | ||
; param=value ; assign values to parameters | ||
|
||
config_version=5 | ||
|
||
[application] | ||
|
||
config/name="PCK loading" | ||
config/description="This demo shows how you can load and unload exported PCK files at runtime." | ||
run/main_scene="res://main.tscn" | ||
config/icon="res://icon.png" | ||
config/features=PackedStringArray("4.0") | ||
|
||
[rendering] | ||
|
||
quality/driver/driver_name="GLES2" | ||
vram_compression/import_etc=true | ||
vram_compression/import_etc2=false |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://cynxmx85sit6h"] | ||
|
||
[ext_resource type="Texture2D" uid="uid://deyknasv78sq2" path="res://icon.png" id="1_o57oj"] | ||
[ext_resource type="Script" path="res://script1.gd" id="2_u8kao"] | ||
|
||
[node name="Node2D" type="Node2D"] | ||
|
||
[node name="Label" type="Label" parent="."] | ||
offset_right = 40.0 | ||
offset_bottom = 23.0 | ||
text = "Greetings from 1.pck!" | ||
|
||
[node name="Sprite2D" type="Sprite2D" parent="."] | ||
position = Vector2(23, 41) | ||
scale = Vector2(0.5, 0.5) | ||
texture = ExtResource( "1_o57oj" ) | ||
script = ExtResource( "2_u8kao" ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.