Skip to content

Commit

Permalink
This gets past the first problem: the issue seems to be the broken ui…
Browse files Browse the repository at this point in the history
…d that gets produced for ext_resource
  • Loading branch information
migueldeicaza committed Sep 24, 2023
1 parent e745d61 commit 439ec27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 11 additions & 2 deletions Sources/SwiftGodotEditorExtension/SwiftResourceFormatLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,23 @@ class SwiftResourceFormatLoader: ResourceFormatLoader {
}

open override func _load(path: String, originalPath: String, useSubThreads: Bool, cacheMode: Int32) -> Variant {
pm ("Request to load path=\(path) originalPath=\(originalPath) useSubthreads=\(useSubThreads) cacheMode=\(cacheMode) -> RETURNING 1")
var rootPath = ProjectSettings.shared.globalizePath(path)
pm ("Request to load path=\(path) originalPath=\(originalPath) useSubthreads=\(useSubThreads) cacheMode=\(cacheMode)")
var rootPath: String

if path.hasSuffix("res://Sources/\(extensionName)/") {
rootPath = ProjectSettings.shared.globalizePath(path)
} else {
rootPath = ProjectSettings.shared.globalizePath("res://Sources/\(extensionName)/\(path.dropFirst (6))")
}
pm ("RESOLVED PATH: \(rootPath)")
guard let contents = try? String (contentsOfFile: rootPath) else {
pm ("_LOAD: Failed to load the contents of \(rootPath)")
return Variant (Int (GodotError.errCantOpen.rawValue))
}
let script = SwiftScript()
script.resourcePath = path
script.sourceCode = contents
pm ("_LOAD: RETURNING SCRIPT")
return Variant (script)
}
}
Expand Down
5 changes: 4 additions & 1 deletion TestEditor/node_2d.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[gd_scene format=3 uid="uid://b2yh1fspd2mci"]
[gd_scene load_steps=2 format=3 uid="uid://b2yh1fspd2mci"]

[ext_resource type="Script" path="res://Anotjer.swift" id="1_8tx7h"]

[node name="Node2D" type="Node2D"]

[node name="Node" type="Node" parent="."]
script = ExtResource("1_8tx7h")

[node name="Node2" type="Node" parent="."]

0 comments on commit 439ec27

Please sign in to comment.