As a developer it’s difficult to manage certain states of the development environment. Right now you are more or less expected to keep the datamodel at an always-ready-to-publish state just in case the user tries publishing. This can be very performance heavy and cumbersome when using sufficiently custom workflows.
For example, when editing meshes inside Roblox Studio you have to always publish the mesh as soon as possible because an unpublished mesh won’t function correctly in a published game. If the user publishes the game before the plugin is able to prepare the datamodel then the user could end up publishing a broken build.
So my solution to this is a callback plugins can register. The publish workflow invokes all the on-publish callbacks when the user tries to publish. And it waits until the callbacks finish before the publish actually goes through.
This would be greatly appreciated, it’s pretty hacky putting things under Camera to be visible in the workspace while not getting published.
If I could add though, instead of a callback maybe methods like :BindToPlacePublish(label, fn) and :UnbindFromPlacePublish(label) would be ideal so that
When publishing, a modal could appear showing which binds from which plugins are currently stopping the publish (so if a plugin is broken, you can at least know which one to uninstall)
Multiple plugins can use the same method rather than just a single callback needing to be shared
I really want this… my current super-hacky workaround is to check InsertService:GetLatestAssetVersionAsync() on the current game.PlaceId every few seconds, and see if it changes. But I don’t like this because it can’t fire immediately on publish, and it spams network requests.
I have a specific use case where I want to use AssetService:CreateAssetVersionAsync() to automatically publish a new version of a model whenever I publish a new version of a specific place. I need the model’s contents to always be up-to-date with the latest version of the place.
Some ideas I had
Add a method under the Plugin object: Plugin:BindToPublish(). It takes a function as its first parameter, which would be called with three values:
The game.GameId you published to.
The game.PlaceId you published to.
A bool indicating whether the new version was published or not.
Multiple functions can be bound. Any attempt to save/publish the current place in Studio would yield until all bound functions have completed.
There is a timeout of 30 seconds, after which, if any bound functions are still running, the save/publish will happen regardless.
Example:
plugin:BindToPublish(function(gameId, placeId, wasPublished)
--some code that should run before the publish happens
end)