Reputation: 383
This is my app code, trivial:
import SwiftUI
@main
struct LogicVisionApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}.windowStyle(.volumetric)
}
}
This is my ContentView code:
import SwiftUI
import RealityKit
import RealityKitContent
struct ContentView: View {
init() {
// Register components
DraggableComponent.registerComponent()
[snip...]
// Register systems
TransmittableStaticInitSystem.registerSystem()
[snip...]
NSLog("I am running?!")
}
var body: some View {
RealityView { content in
// Add test entities
let testWire = try! Entity.load(
named: "Wire",
in: realityKitContentBundle)
content.add(testWire)
[snip...]
NSLog("I am running 2?!")
}
.gesture(DragGesture(coordinateSpace: .global)
.targetedToEntity(
where: QueryPredicate<Entity>.has(DraggableComponent.self))
.onChanged { value in
value.entity.position = value.convert(
value.location3D,
from: .global,
to: value.entity.parent!)
}
)
}
}
#Preview {
ContentView()
}
Upvotes: 1
Views: 886
Reputation: 9267
I suspect the volumetric window is clipping your content. Try adding the .fixedSize()
modifier to the RealityView
.
Alternatively you can add a .defaultSize(width: height: depth: in:)
to the Volumetric WindowGroup in order to scale it to the appropriate size to fit the RealityView's content. ie.
.defaultSize(width: 2.0, height: 2.0, depth: 2.0, in: .meters)
You should be able to get logs from preview content, in Xcode next at the bottom of the log window is a "Previews" toggle which should give you logs from the preview.
Upvotes: 2