Skip to content

Load scenes into GodotWindow #8

@pluviamtonitrus

Description

@pluviamtonitrus

I'm trying to instantiate a PackedScene into a GodotWindow

let loadScene = { (subwindow: Window) -> () in
    if let scene: PackedScene = GD.load(path: "res://scene_2.tscn") {
        if let node: Node = scene.instantiate() {
            subwindow.addChild(node: node)
        }
    }
}

struct ContentView: View {
    @StateObject var app = GodotApp()
    
    var body: some View {
        VStack {
            GodotAppView()
            GodotWindow(callback: loadScene)
        }
        .padding()
        .environmentObject(app)
        .onAppear(perform: {
            app.createInstance(scene: "main.pck")
        })
    }
} 

but it causes GodotAppView to change its scene to scene_2.tscn as well.

Is there a way to run multiple scenes that are packed into a .pck file?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions