Skip to content
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

Adds simple updater to ScenelessProject #120

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hudbuddy
Copy link
Contributor

@hudbuddy hudbuddy commented Oct 29, 2024

We need a way to ensure that older projects are kept up to date when the ScenelessProject create() method changes.

This adds a basic function that should be called upon loading a project to ensure it has all of the components expected by ScenelessProject commands


Currently, existing projects encounter a breaking error on startup:

image

This is because audioContainer was never created.

https://xsolla.atlassian.net/browse/LSTREAM-678


// In lieu of a versioning system, this can be used
// to update a ScenelessProject if its base structure changes.
export const updateToLatest = async (_project: ScenelessProject) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, there's a series of ensure* functions in this file that are called when a project loads. If this function isn’t much different from those, I'd recommend moving it to that list to keep things uniform. This way, we won’t need to call it manually from Studio-next.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I already did this, but maybe it got deleted during some revision.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maddygoround

good point on the ensure(). The main problem is that these methods run asynchronously while the commands returns synchronously, so we're setting ourselves up for a race condition.

But I'd rather not have two different places where we handle this logic, so I'll keep this PR up as a reference until we decide on a unified solution

// Ensure audioContainer exists
const audioContainer = root.children.find((x) => x.props.id === 'audio')
if (!audioContainer) {
await coreProject.compositor.insert(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's possible to insert at a specific index, let's insert at index 0 please. I know that this layer is invisible, but in case that gets broken somehow, it will at least then be rendering in the back, which is the next best thing I think


// In lieu of a versioning system, this can be used
// to update a ScenelessProject if its base structure changes.
export const updateToLatest = async (_project: ScenelessProject) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I already did this, but maybe it got deleted during some revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants