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
[unity] Delayed on-demand loading of Atlas assets #1890
Comments
Is there any plan to implement this soon? Our game is having memory issue related to this, it could really use this feature |
@jacattrongnlh If you need a solution soon, we would highly recommend implementing a solution on your own in the meantime. |
…ayed on-demand loading of Atlas assets. See #1890.
First of all, sorry for the long delay! You can try it out using the following steps:
https://github.com/EsotericSoftware/spine-runtimes.git?path=spine-unity/Modules/com.esotericsoftware.spine.on-demand-loading#4.1 If you've installed the spine-unity runtime via unitypackage, you need to download the two packages above and before adding them to your project remove the line For usage of the Addressables on demand loader package, please see the readme.md file in Please share your thoughts on the forum, especially if you encounter any problems or have ideas for improvement. |
…hic. Added method `RequestLoadTexture` and TextureRequested delegate to OnDemandTextureLoader. Fixed missing loader asset name suffix. See #1890.
On-demand (Addressables) texture loading now supports SkeletonGraphic. New spine-unity 4.1 and 4.2-beta unitypackages are available for download: You can update and try out the two UPM packages as described in the above comment. As always, please let us know if you encounter any issues or have any ideas for improvement. :) |
I needed something like this for the project, and decided to test it. It kinda does what I wanted in theory, but:
|
@Gamer-XP Sorry to hear you're having troubles. Unfortunately we could not reproduce any of this behaviour, testing any Configurable Enter Play Mode options as well. Could you please send us a minimal Unity project which still shows this issue? You can send it as a zip package to contact@esotericsoftware.com, briefly mentioning this issue ticket URL so that we know the context. Please also note that activating the placeholder textures via |
Maybe I'm misunderstanding something. Actually, I planned on using those placeholders as temporary graphics behore Unity loads full-res assets from the server. So, I assume player may actually see them for a while if net or device is slow. That's why I find it weird that those placeholders are quite buggy. And yes, after testing, this issue happens only if I used Assign Placeholders before starting the game - it won't revert materials back to placeholders after game end, instead I get null textures there. Also, didn't know about pre-build step. Still, about that. I'm not 100% sure yet, but it doesn't seem to work with building addressables themselves at least. I tried doing analyze for duplicates, and seems like it still includes high-res texture in both addressable bundle and main project if you have spine object in the scene at least. This is the reason I tried to use low-res texture for the material as default - because I wanted to remove reference to the high-res one to prevent this duplication. I'm using Unity 2022.3.30f, Runtime 4.2-beta btw |
@Gamer-XP The placeholder assets are assigned automatically to avoid having blurry low-res textures during development, or having to replace them all manually before building, either of which would be terrible to work with.
If reset after exiting play mode does not work as expected, please send us a minimal reproduction Unity project as described above, so that we can fix the issue.
Did you assign the normal high-res textures at an addressable bundle? Or did you leave it at
Thanks for the info, sorry to hear. We would really like to fix the issue if it behaves like that in your project. As mentioned above, it would help us a lot if you could send us a minimal Unity reproduction project. |
@Gamer-XP BTW: Unity version 2022.3.30f does not exist yet, 2022.3 is at 2022.3.11f currently. Did you mean 2021.3.30f? |
Yep, sorry, a typo. 2021.3.30f. |
@Gamer-XP Great, thanks. |
Here you are:
|
@Gamer-XP Thanks for sending the reproduction project. Please note that the Regarding the other more important issues you reported above: |
Weird. It works fine in the example project for me too, but is bugged in the actual one. I'll try checking what's going on here. |
@Gamer-XP Thanks for confirming. Please have a check whether the version in the original project is really |
Fixed an issue with editor not resetting on-demand loaded textures after exiting play mode, see commit 7eea8ce. |
Thanks. I'll check it when I get time. |
This commit looks like it increases the build time. With this commit included, our project's build time jumped from 10 minutes to 20. Reverting this commit could get our build time back to normal. |
@liuxiaotian Thanks for reporting and sorry for the troubles. I assume you mean the last commit above, 7eea8ce, right? We will have a look at it. |
@liuxiaotian Unfortunately we could not reproduce the issue. When starting or ending a build, this callback of changing play mode should not be called at all. Even if it were called, only the assets of type Which exact commit did you revert? Could you add a Or even better: could you perhaps create a minimal Unity project which still shows this issue? If so, you can send it to contact@esotericsoftware.com, briefly mentioning this issue ticket so that we know the context. |
Sorry for the late reply. I'm using Unity 2020.3.41f1, the commit is 76e8538. [MenuItem("Test/Spine Preprocess Build")]
static void Menu()
{
var sw = new Stopwatch();
sw.Start();
SpineBuildProcessor.PreprocessBuild();
sw.Stop();
UnityEngine.Debug.LogError($"Total time: {sw.ElapsedMilliseconds}ms");
} |
hi @HaraldCsaszar, first of all thanks a lot for the initiative of On-demand and Addressables modules. We have a character with 70+ skins and all the textures is getting loaded into the Memory, but now with these modules we were able to solve this issue. It has almost 1 month since we started to investigate how to use the modules, and came up with different results:
After days of investigation, today I found the reason for the 3 failures above... By default, the Addressables Build process starts before the App Build process. That means this line below is executed only after the Addressables already got completely finished with all the Materials using the original High resolution textures.
In our project, the build pipeline has already a system in place where I can trigger the |
@sandolkakos Thanks very much for the feedback and for sharing your insights, these are very valid points! Sorry you were having troubles. We will have a look at what we can do to automatically cover these cases as well without adding any overhead. |
…and newer (using BuildPlayerProcessor). See #1890.
@sandolkakos Thanks again for reporting your issue. The above commit for spine-unity (the core-package) on the 4.2-beta branch fixes pre-build-step order in Unity 2021.2, where Addressables and AsserBundles are built before the Details: This was due to Since this could be a breaking change for existing build pipelines on 4.1, this change has been pushed to 4.2-beta only. The above change should automatically fix the order of pre-processing on-demand-loaded textures before building Addressables via |
For building addressable only, the solution I've made is custom shemes (AddressableAssetGroupSchema) + custom addressable builder script (BuildScriptPackedMode). I don't think there is any way to modify existing build pipeline for addressables. At least, I couldn't find anything. |
Thanks a lot for that fix, @HaraldCsaszar. I'm always happy to help. |
@sandolkakos Glad it helps, thanks for your reply! If you find anything how we can further improve build automation, don't hesitate to let us know. |
In our project, we use Github actions to build the App, and before starting the build we can prepare a lot of stuff on the project. [InitializeOnLoad]
public static class LocalBuildScript
{
static LocalBuildScript()
{
if (Application.isBatchMode)
{
// This script should not be used in batch mode.
return;
}
BuildPlayerWindow.RegisterBuildPlayerHandler(BuildPlayerConfirmation);
}
private static void BuildPlayerConfirmation(BuildPlayerOptions options)
{
// Implement the pre-build preparations here
// Continue the build
bool success = BuildPipeline.BuildPlayer(options);
}
} |
But I'm pretty sure it will not solve the problem for build the Addressables via Addressables Group window. |
@sandolkakos Thanks for the info, always much appreciated. Unfortunately I'm afraid this will cover just the scenarios that are already covered by the |
Mentioned on the forum here:
http://esotericsoftware.com/forum/How-to-control-texture-memory-usage-for-skeleton-with-skins-13240
http://esotericsoftware.com/forum/I-tried-to-export-with-command-line-but-not-file-is-created-14258?start=25
Also requested on this forum thread:
http://esotericsoftware.com/forum/Memory-management-of-character-with-many-outfits-15867
In Unity all referenced assets are automatically loaded, so there should be a comfortable way provided that allows to:
green/
ortier4/
. There should be a checkboxLoad on-demand
provided in the Inspector to enable on-demand loading.Auto unload
shall be configurable per atlas asset as an Inspector checkbox.Implementation notes:
ad 1:
AtlasAssetBase[] atlasAssets
. Current logic just reports error messages when not all attachments are found and will then be reset upon reimport, losing assigned atlas assets.ad 2:
The text was updated successfully, but these errors were encountered: