Dynamic Queries and adding dynamic components' data #11424
-
I'm playing around with the dynamic queries API that @james-j-obrien developed for the game engine, and I'm trying to add String data to my dynamically created components. I have been following the example here, but I'm having problems adapting it to add a String to the component instead of an array of u64. I'm assuming that is possible, but my programming-fu isn't working. Help? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Just bumping this discussion. My code to try to add String data to the component is below: `let cell_value = cell.get_value().into_owned(); // A string let ptr = unsafe { This compiles, but when the code is run, it eventually exits without running to completion. I know my problem is in the above block of code, but I don't know how to fix it. |
Beta Was this translation helpful? Give feedback.
You have a pretty good understanding but there is one wrinkle in that the type in the example actually represents
struct CompA([u64, X])
where X is some dynamically defined size (note the lack of a reference, it's stored inline). The purpose in using that type for the example is to show that the dynamic components can have their sizes chosen dynamically as well, for use cases where you don't know what data you need to store. I do understand nicopap's argument that it is somewhat niche however this is the only way to demonstrate "fully" dynamic components, we could also add a simpler variant that uses a known layout.Since you know the exact layout of the data you want to store in your com…