- Modificato
How to import spine files completely during runtime?
Hello, firstly, I'm sorry, i only did half an hour research into this so far, but I'm under a deadline and panicking a bit, so I'm posting this question too soon so that it can sit here and maybe collect some responses while I continue my research...
Secondly - as the title says... The spine lib has some editor asset importer scripts (which i haven't located and therefore haven't looked at yet) which take the generated files and generate some extra files in unity on import...
...i have just learned i need to remove this step. I need to be able to load the spine exports directly, at runtime, removing the intermediary steps of "let the editor scripts generate the files which are then actually used".
So far, it seems to be somewhat possible - if i basically re-wrote the importers or whatever they do, basically manually parsing and reading the spine exports, and manually constructing the spine objects based on that. For this, even pointing me to where are the spine importer scripts handling this, would help.
Which is... something.
Something kind of scary, since I only have 40 hours budgeted for the WHOLE project, and so far it seems to me doing just the "import at runtime" part would cost me at least 20 hours.
Any better solutions/tips/pointers to something that might help?
Thank you, and again, sorry for asking so soon with having done so little research beforehand.
P.S. Yes, I am very new to the whole spine workflow, so hopefully, I have overlooked or not yet learned about something very obvious which immediately solves at least half of my problem. Sorry about that, but I'm in full panic mode and therefore reaching out in all the directions I can think about. Thank you for understanding.
http://139.162.66.173/forum/Texture-Packing-at-Runtime-1860
i have found this (amongst other things), which hints at what i said - the theoretical possibility of rebuilding the whole spine object at runtime, but... at the same time, it doesn't seem to be exactly the correct way (unless "attachment" is spine's word for "whatever is plopped onto the bone", and even then, I'd have to manually rebuild the skeleton, which I haven't yet looked into whether it's possible or not).
Sorry to hear that you have just so little time budget allocated for that! We have good news for you however, you just need to have a look at the example script Spine Examples/Scripts/RuntimeLoadFromExportsExample.cs
here.
I have renamed it from DataAssetsFromExportsExample
to RuntimeLoadFromExportsExample
since admittedly the previous name was not very easy to find.
Regarding the texture repacking URL that you posted above: it's very outdated, the current way to combine skins and repack texture is describes here:
spine-unity Runtime Documentation: Combining Skins
You should not need texture repacking for your use case anyway, just stating for later reference.
Harald ha scrittoyou just need to have a look at the example script
Spine Examples/Scripts/RuntimeLoadFromExportsExample.cs
(https://github.com/EsotericSoftware/spine-runtimes/blob/4.0/spine-unity/Assets/Spine%20Examples/Scripts/RuntimeLoadFromExportsExample.cs).I have renamed it from
DataAssetsFromExportsExample
toRuntimeLoadFromExportsExample
since admittedly the previous name was not very easy to find.Regarding the texture repacking URL that you posted above: it's very outdated, the current way to combine skins and repack texture is describes here:
spine-unity Runtime Documentation: Combining Skins
You should not need texture repacking for your use case anyway, just stating for later reference.
First of all, thank you incredibly much for the swift and... full answer.
I'm currently using the 3.8 plugin, so there it's still DataAssetsFromExports, and... yes, I think I wouldn't have realized what I'm looking at even if I was looking at it directly. The new name is much better
Secondly, once again I apologise for not having found it.
P.S. have you ever tried to google this question? I'm not sure if it's just my personalized search messed up, but I went through all the search results up to when the personal blogs written partially in asian languages show up, and... I have not seen a single result for "unity3d load spine (animations/files) at runtime" that would actually mention that example.
Not trying to excuse myself, or blame it on you, just saying.
Once again, thank you so much, you've literally just saved me 3 days of terrified panic. I hope you're having a beautiful week
P.P.S.
Looking at the example now... Oh my god, that's beautiful. I thought it should be/hoped it would be just a few lines, taking the correct objects and plugging them into the correct functions, but... this is even less, even better, than I hoped for
If I didn't panic, and just kept on calmly exploring the intellisense, I might have been able to figure it out by trial and error, even, probably in a day. What I meant to say by that is - your API seems nice. A bit too subdivided for my personal taste, but I bet the more I learn about what spine can do, the more the segmentation is going to make sense, however, it seems nicely organized . I'm seeing those 10 lines of code, and they all make sense, even to me, a complete newbie to the tech.
Good work, you guys
Thanks for your kind words, glad it was helpful!
sh_code ha scrittoP.S. have you ever tried to google this question? I'm not sure if it's just my personalized search messed up, but I went through all the search results up to when the personal blogs written partially in asian languages show up, and... I have not seen a single result for "unity3d load spine (animations/files) at runtime" that would actually mention that example.
Not trying to excuse myself, or blame it on you, just saying.
Thanks for the feedback, much appreciated! We will add a documentation section to the spine-unity documentation page, admittedly this topic is not well documented yet.
Actually instantiating skeletons directly from exported assets is not something that we recommend if it can be avoided. We very much recommend to go the normal workflow through letting the Editor import the assets and create the respective SkeletonDataAsset
and SpineAtlasAsset
assets. For this we have an example scene named Instantiate from Script
which requires a previously setup SkeletonDataAsset
to work with. Nevertheless, if your requirements are to work from those three exported assets, this will not be of much help of course.
We have added a section Advanced - Instantiation at Runtime
to the spine-unity docs here:
spine-unity Runtime Documentation: Advanced Instantiation at Runtime
We hope that this will be found more easily by search engines.