-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - Add writing of scene data to Scene example #5949
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! IMO we should write the scene to a new file to avoid altering the loaded data (and gitgnore the generated file).
bors r+ |
# Objective Alice says to make this PR: https://discord.com/channels/691052431525675048/745805740274614303/1018554340841107477 - The "scene" example in the examples folder has a TODO comment about writing the serialized data to a file. This PR implements that. ## Solution The `AssetIo` trait in the `AssetServer` only supports reading data, not writing it. So, I used `std::io::File` for the implementation. This way, every time you run the example, it will mutate the file in-place. I had thought about adding a UUID string to the example Component, so that every time you run the example, the file will be guaranteed to change (currently, it just writes the same numbers over and over). However, I didn't bother because it was beyond the scope of the TODO comment. One thing to note is that the logic for serializing the scene into RON data has changed since the existing RON file was created, and so even though the data is the same, it's rendered in a different order for whatever reason. I left the changed output to the example file, because it's presumably trivial. I can remove it and force-push if you don't want that included in here.
Pull request successfully merged into main. Build succeeded: |
This is a bad idea, and we should really not show usage of a blocking api (file writing) in a system. |
@mockersf What alternative do you suggest for this use case? |
ideally, the asset server should be able to write assets... But for now, we can just wrap it in a task: #5952 |
# Objective Alice says to make this PR: https://discord.com/channels/691052431525675048/745805740274614303/1018554340841107477 - The "scene" example in the examples folder has a TODO comment about writing the serialized data to a file. This PR implements that. ## Solution The `AssetIo` trait in the `AssetServer` only supports reading data, not writing it. So, I used `std::io::File` for the implementation. This way, every time you run the example, it will mutate the file in-place. I had thought about adding a UUID string to the example Component, so that every time you run the example, the file will be guaranteed to change (currently, it just writes the same numbers over and over). However, I didn't bother because it was beyond the scope of the TODO comment. One thing to note is that the logic for serializing the scene into RON data has changed since the existing RON file was created, and so even though the data is the same, it's rendered in a different order for whatever reason. I left the changed output to the example file, because it's presumably trivial. I can remove it and force-push if you don't want that included in here.
# Objective - Fix bevyengine#5951 - Improve on bevyengine#5949 by not risking blocking a system ## Solution - Wrap file writing in a task
# Objective Alice says to make this PR: https://discord.com/channels/691052431525675048/745805740274614303/1018554340841107477 - The "scene" example in the examples folder has a TODO comment about writing the serialized data to a file. This PR implements that. ## Solution The `AssetIo` trait in the `AssetServer` only supports reading data, not writing it. So, I used `std::io::File` for the implementation. This way, every time you run the example, it will mutate the file in-place. I had thought about adding a UUID string to the example Component, so that every time you run the example, the file will be guaranteed to change (currently, it just writes the same numbers over and over). However, I didn't bother because it was beyond the scope of the TODO comment. One thing to note is that the logic for serializing the scene into RON data has changed since the existing RON file was created, and so even though the data is the same, it's rendered in a different order for whatever reason. I left the changed output to the example file, because it's presumably trivial. I can remove it and force-push if you don't want that included in here.
# Objective - Fix bevyengine#5951 - Improve on bevyengine#5949 by not risking blocking a system ## Solution - Wrap file writing in a task
# Objective Alice says to make this PR: https://discord.com/channels/691052431525675048/745805740274614303/1018554340841107477 - The "scene" example in the examples folder has a TODO comment about writing the serialized data to a file. This PR implements that. ## Solution The `AssetIo` trait in the `AssetServer` only supports reading data, not writing it. So, I used `std::io::File` for the implementation. This way, every time you run the example, it will mutate the file in-place. I had thought about adding a UUID string to the example Component, so that every time you run the example, the file will be guaranteed to change (currently, it just writes the same numbers over and over). However, I didn't bother because it was beyond the scope of the TODO comment. One thing to note is that the logic for serializing the scene into RON data has changed since the existing RON file was created, and so even though the data is the same, it's rendered in a different order for whatever reason. I left the changed output to the example file, because it's presumably trivial. I can remove it and force-push if you don't want that included in here.
# Objective - Fix bevyengine#5951 - Improve on bevyengine#5949 by not risking blocking a system ## Solution - Wrap file writing in a task
Objective
Alice says to make this PR: https://discord.com/channels/691052431525675048/745805740274614303/1018554340841107477
Solution
The
AssetIo
trait in theAssetServer
only supports reading data, not writing it. So, I usedstd::io::File
for the implementation. This way, every time you run the example, it will mutate the file in-place.I had thought about adding a UUID string to the example Component, so that every time you run the example, the file will be guaranteed to change (currently, it just writes the same numbers over and over). However, I didn't bother because it was beyond the scope of the TODO comment.
One thing to note is that the logic for serializing the scene into RON data has changed since the existing RON file was created, and so even though the data is the same, it's rendered in a different order for whatever reason.
I left the changed output to the example file, because it's presumably trivial. I can remove it and force-push if you don't want that included in here.