Reputation: 2127
I'm learning sample code SceneKit team demonstrated in SceneKit: What's New.
I find a file has extension .gks
and it seems is resource of GameplayKit
.
Here is it loading:
#if EnableGamePlayKit
_gkScene = [GKScene sceneWithFileNamed:@"Art.scnassets/scene.gks" rootNode:_scene];
#endif
What's the .gks
file? I keep looking for a long time but failed. How to create and use it?
Upvotes: 0
Views: 321
Reputation: 16837
There is zero documentation on this that I can find, it took me hours to get this to properly work. The gks file is automatically generated when you add components to your scene via the SceneKit builder. it will automatically create GKEntity
and GKSCNNodeComponent
instances for nodes that have components attached to them, so that you can use them without ever having to create them via code.
Note, this method is horrendously bugged. After you create the GKScene
, you need to go through the entities and remap the components to the entity it is given, because the entity variable in the component stays as nil. You also need to re-add a copy of the component back into the entity, because when you try to find the component with OfType
, it will not recognize the type, even though you can print the contents of the entity and clearly see that everything is declared the same type. I will update this answer later on for people so that they can see code as to how to get this to work properly.
Upvotes: 0
Reputation: 13462
A .gks
file is created by archiving a GKScene
instance using NSKeyedArchiver
. You can learn more about GameplayKit on the Apple developer website.
Upvotes: 1