Hi @Miro
Components in a framework will not show up in Reality Composer Pro.If your goal is to encapsulate your System in a framework, you can get close using the following approach.
- In your framework, define a protocol for the component and a system, that takes a generic that implements the component protocol.
- Instruct people who use your framework to create a component that implements the protocol, register that component and the system, passing it that component.
For example, if you want your framework to contain a reusable Bubble system you would follow these steps:
In BubbleFramework
define BubbleComponentProtocol
and BubbleSystem
.
protocol BubbleComponentProtocol : Component, Codable {
var burst:Bool {get}
var direction:simd_float3 {get}
}
struct BubbleSystem<T:BubbleComponentProtocol>: System {
let query = EntityQuery(where: .has(T.self))
public init(scene: Scene) {
}
public func update(context: SceneUpdateContext) {
let bubbles = context.entities(matching: self.query,
updatingSystemWhen: .rendering)
for bubble in bubbles {
guard let component = bubble.components[T.self] else {continue}
// do things with the bubble component
}
}
}
In the consuming app's Reality Composer Pro package, add a dependency to BubbleFramework
then implement BubbleComponentProtocol
.
public struct BubbleComponent : BubbleComponentProtocol, Codable {
var burst = false
var direction:simd_float3 = [0.1, 0.1, 0.1]
}
In the app, that uses the RCP package, register the component and system in the app's initializer.
BubbleComponent.registerComponent()
BubbleSystem<BubbleComponent>.registerSystem()
BubbleComponent
should now appear in Rwaking Composer Pro.
Please accept this answer if it answers your question. If you need more help, please follow up so I can help you achieve your goal.