-
-
Notifications
You must be signed in to change notification settings - Fork 986
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
feat: User-defined assets support (ScriptableObject like data types and more) #2527
base: master
Are you sure you want to change the base?
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.
Good job on making this one work!
package.Assets.Add(newAssetItem); | ||
AssetItem = newAssetItem; | ||
PropertyGraph?.Dispose(); | ||
Session.GraphContainer.UnregisterGraph(assetItem.Id); |
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.
I think there's an implicit assumption here that previous asset item Id is equal to the new one. Would be good to verify it explicitly (at least with Debug.Assert).
…change listener on editor dispose
Cleaned up as much as I could, still a fair amount of logic that might be fragile, but I'm at a point were things are just too obtuse to investigate further. |
There is already a mechanism to handle type reloading, but it works only if it's inside an asset (as part of a property, member or list), not for the top-level asset itself. I am currently testing/checking which option would make more sense:
Another important point is to handle failed/unloadable assets just like we do for properties (either due to assembly not compiling or any other Yaml mismatch) so I will try to check which of those strategy fit better considering this as well. |
I had to dig a bit deeper than expected because I ran into a situation that was not working properly (unrelated to your changes for custom asset). So I spent some time to understand the various quantum nodes/reloading/propagator system and could finally fix this bug. I did some tests and now it seems I can get proper reload for assets, components and references (tested on https://github.com/manio143/StrideCustomAsset). Also, it should be not so difficult to add support to "unloadable assets" (just like we do for unloadable components/part of assets, this was just not possible at the top-level) since it would work the same way as we do for reload. You can give it a try there: |
… a bug where ClearContentReferences() was not called on content references inside a removed object (resulting in crash).
@@ -715,5 +683,33 @@ public void PrepareSave(ILogger logger) | |||
{ | |||
PropertyGraph?.PrepareForSave(logger, assetItem); | |||
} | |||
|
|||
public void UpdateAsset(Asset newAsset, ILogger loggerResult) |
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.
Any particular reason to move the method here? Usually we have public method first, then protected, then private.
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.
Moved it back, I'll let @xen2 chime in if this was on purpose
sources/editor/Stride.Assets.Presentation/AssemblyReloading/GameStudioAssemblyReloader.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
AssemblyRegistry.AssemblyRegistered += (sender, args) => |
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.
We might need to make AssetNodeContainer
be IDisposable
and unregister to those events when disposing. I'm thinking this might otherwise cause some issues when re-opening a projhect or opening a new project from within the Game Studio (without closing it).
PR Details
WIP right now - it works but barely. I feel like most of the logic shouldn't be where I ended up shoving it, would need someone aware of how quantum, the assembly reloader and the undo system work to check over this one.
To create an asset, see this page https://github.com/stride3d/stride-docs/blob/master/en/manual/scripts/custom-assets.md or @manio143 's https://github.com/manio143/StrideCustomAsset
Related Issue
#30
Types of changes
Checklist