Hi, for my Swift Student Challenge, I'd like to store persistent data.
User would be able to "Mark as done" a task, which will then be stored.
However I'm not a huge fan of CoreData, which is very complicated.
SwiftData would be perfect, but it's only available in iOS 17, and playgrounds are iOS 16 and newer.
I could also use an external library, such as Realm DB.
I really would like to use SwiftData but it seems very compromised.
I red that third-part libraries are not forbidden (https://forums.developer.apple.com/forums/thread/74533) so I could technically use Realm (https://realm.io/)
Can anyone help me with this choice ? Thanks!
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello, I'm struggling trying to interact with a RealityKit entity nested (or at least visually nested) in a second one.
I think I've the same issue as mentioned on this StackOverflow post, but I can't manage to reproduce the solution. https://stackoverflow.com/questions/79244424/how-to-prioritize-a-specific-entity-when-collision-boxes-overlap-in-realitykit
What I'd like to achieve is to translate the red box using a DragGesture, while still be able to interact using a TapGesture on the sphere. Currently, I can only do one at a time.
Does anyone know the solution?
extension CollisionGroup {
static let parent: CollisionGroup = CollisionGroup(rawValue: 1 << 0)
static let child: CollisionGroup = CollisionGroup(rawValue: 1 << 1)
}
struct ImmersiveView: View {
var body: some View {
RealityView { content in
let boxMesh = MeshResource.generateBox(size: 0.35)
let boxMaterial = SimpleMaterial(color: .red.withAlphaComponent(0.25), isMetallic: false)
let boxEntity = ModelEntity(mesh: boxMesh, materials: [boxMaterial])
let sphereMesh = MeshResource.generateSphere(radius: 0.05)
let sphereMaterial = SimpleMaterial(color: .blue, isMetallic: false)
let sphereEntity = ModelEntity(mesh: sphereMesh, materials: [sphereMaterial])
content.add(sphereEntity)
content.add(boxEntity)
boxEntity.components.set(InputTargetComponent())
boxEntity.components.set(
CollisionComponent(
shapes: [ShapeResource.generateBox(size: SIMD3<Float>(repeating: 0.35))],
isStatic: true,
filter: CollisionFilter(
group: .parent,
mask: .parent.subtracting(.child)
)
)
)
sphereEntity.components.set(InputTargetComponent())
sphereEntity.components.set(HoverEffectComponent())
sphereEntity.components.set(
CollisionComponent(
shapes: [ShapeResource.generateSphere(radius: 0.05)],
isStatic: true,
filter: CollisionFilter(
group: .child,
mask: .child.subtracting(.parent)
)
)
)
}
}
}