SharePlay Button

I followed the WWDC video to learn Sharplay. I understood the first creation of seats, but I couldn't learn some of the following content very well, so I hope you can give me a list code. The contents are as follows:

I have already taken a seat.

struct TeamSelectionTemplate: SpatialTemplate {
    let elements: [any SpatialTemplateElement] = [
        .seat(position: .app.offsetBy(x: 0, z: 4)),
        .seat(position: .app.offsetBy(x: 1, z: 4)),
        .seat(position: .app.offsetBy(x: -1, z: 4)),
        .seat(position: .app.offsetBy(x: 2, z: 4)),
        .seat(position: .app.offsetBy(x: -2, z: 4)),
    ]
}

I hope you can give me a SharePlay Button. After pressing it, it will assign all users in Facetime to a seat with elements quantified in TeamSelectionTemplate. Thank you very much.

Answered by DTS Engineer in 791433022

Please take a look at this sample code project which shows how to setup multiplayer with SharePlay and SpatialTemplates. Creating tabletop games

Please take a look at this sample code project which shows how to setup multiplayer with SharePlay and SpatialTemplates. Creating tabletop games

Hi! The sample associated with that session is available here: https://developer.apple.com/documentation/groupactivities/customizing-spatial-persona-templates.

I hope you can give me a SharePlay Button. After pressing it, it will assign all users in FaceTime to a seat with elements quantified in TeamSelectionTemplate.

That sample does include a SharePlayButton you can consider using. However, that button doesn't do exactly what you're describing.

When using SharePlay on visionOS with spatial Personas, seat assignment happens automatically when you join a SharePlay activity's group session. In the "Guess Together" sample, pressing the SharePlay button will either start a new session with the existing FaceTime call, or join the existing one if it exists. At that time, if you've selected the TeamSelectionTemplate as your spatial template preference, FaceTime will assign each user to a seat in that template.

systemCoordinator.configuration.spatialTemplatePreference = .custom(TeamSelectionTemplate())
SharePlay Button
 
 
Q