Vitaly

Hi
There is a character, can change his clothes and hairstyles. For example, I changed my hairstyle - how do I save the data so that when I run it again, the hairstyle changes are saved?
Vitaly
  • Сообщения: 3

Harald

Please note that this is a general question on how to save (persist) data between play sessions of a Unity game, which is independent of Spine. You should persist your player data (such as player name, player stats, etc) as you normally would, and then trigger the respective Spine skin setup again.

Please search the Unity forum for how to save (persist) data between play sessions here:
https://forum.unity.com/
Аватара пользователя
Harald

Harri
  • Сообщения: 2761

Vitaly

HI
This is the question of how to save the appropriate skin setting for the next login to the game. Saving your name and life is not a problem, but what to save for Spine? slots? attachments? or SkeletonData?
Thanks for the answer)
Vitaly
  • Сообщения: 3

DarkTI

In our game, we have a special class that saves everything that can be changed in spine skeleton during gameplay: attachments names used in every slot where they can be changed, colors of all slots that can be recolored, names of currently used skins, currently used animation names, skeleton flipping bool, skeleton scale float, etc. And all this is applied during loading to spine skeleton.

Perhaps it's possible to just save the whole SkeletonData, no idea. But this way we don't save anything that is not needed to be saved, which I prefer more. In your example, you'd need to save the name of hairstyle attachment (it's a string), and apply it to hairstyle slot upon loading.
Аватара пользователя
DarkTI
  • Сообщения: 21

Vitaly

Thanks for your reply)
Vitaly
  • Сообщения: 3

Harald

Vitaly писал(а):This is the question of how to save the appropriate skin setting for the next login to the game. Saving your name and life is not a problem, but what to save for Spine? slots? attachments? or SkeletonData?
There is no difference between saving player name to chosen clothes, hair color, etc. Save your high-level player info, then call the respective Spine API calls again. Anything like persisting the whole skeleton state is not a good idea in terms of software architecture, this is not clean design. This is as if you have a radio (an old one) and instead of saving different radio station frequencies, you clone the whole radio and put another radio next to it, one radio per radio station. It's better to save only the 3 frequencies, then call
radio.SetFrequency(savedStationFrequency1)
instead of this:
if (useFrequency1)
radio1.turnOn();
else if (useFrequency2)
radio2.turnOn();
else if (useFrequency3)
radio3.turnOn();
Аватара пользователя
Harald

Harri
  • Сообщения: 2761


Вернуться в Unity