- تم التحرير
[Editor 1.8.17] Export files contain no "blank" skins
- تم التحرير
Hi guys!
Assume we have some unit spine model and want to it has 3 ranks with different equipment each. E.g. each rank differs in only helmet (skeleton will have no any other skin placeholders):
"Helmet" placeholder will have next attached textures in appropriate skins
rank0 - <empty>
rank1 - leather_cap
rank2 - paladin_helm
Then we create 3 skins with such names. And the interesting thing is export will gives us only two of these (rank1, rank2 and default).
So, I think skin "rank0" does not export because all it's placeholders are empty. Seems Editor just believes that it is redundant data, but what about my code, because I am know that skin "rank0" should be exists and trying to set it to my skeleton. Of course here I'll get NullPointer every time and I'm think it is not right.
What do you think about it?
I just tried this. You're right, it doesn't export empty skins.
I wonder what Nate thinks.
Hey, my hero still waiting for some official replies and he really wants to be of rank0
It's a bug, will fix soon! Sorry for the delay.
Actually, on second thought there is no benefit to having an empty skin. Instead, set the skin to null. If the skin is null or an attachment cannot be found in the skin, the skeleton will look in the SkeletonData's default skin. The default skin holds all attachments that aren't in a skin in Spine.
I think empty skins benefits uniformity in the data.
If you had a set of different enemies with rank0, rank1, rank2, and some types of enemies had an empty rank0 skin and some enemies had rank0 with stuff in it, the code would have to handle the absence of the rank0 in some because they weren't included in the json.
Though I suppose SkeletonData.findSkin does return a null you could check.
Would it be of some benefit if the game somehow had that empty skin to edit?
Theoretically, a game could have a semantic rank0 that changes its look.
That when some condition is fulfilled, some rank0 skins, instead of being empty, would have something in it, so it gets modified/added to at runtime.
But I guess it is also not terribly difficult to just create and add the skin to the SkeletonData at runtime when findSkin returns null.
But then you'd have to call SetSkin to all existing instances of that skeleton you added the skin to. Though you'd have to call setSlotsToSetupPose either way. I guess the empty rank0 could just be created on initialization of the skeleton data if this was needed.
Still, extra code and mysterious disappearing data. Better leave a note somewhere this if auto-removal of empty skins is going to be a feature.
Thanks! My units became happy like never now!
Hi, Nate!
Seems problem steel alive (1.8.27) and blank skins are not saving (at least into .json).
My heroes are waiting for replies again!
A skin is a container for attachments. If you have no attachments, you don't need a container. The API expects null to mean there is no skin. If you really want a blank skin you can create one at runtime, but I don't think it makes sense for a blank skin to show up in the data.
There should be a warning in the export window that says "You have blank skins. These will not be exported." or something.
Just so it's less mysterious.
Done!
Hi Nate!
Hmm, we got a message on exporting. Seems you decided to leave export mechanics the same. Bad news for my code, now I have to put a couple of dirty condition lines:
String resolveRank() {
switch (unit.getUnitLevel()) {
case RANK0:
if (skeleton.getData().findSkin("rank0") != null) //here it is :(
return "rank0";
else
return "default";
case RANK1:
return "rank1";
case RANK2:
return "rank2";
}
throw new RuntimeException("Unknown rank");
}
This is a realy bad, cuz all of my units have 3 ranks, and I honestly create it in editor...
Well, ok. I clearly understood your motivation. And seems the topic has been exhausted. But the little thing I want to ask for is a check box somewhere in editor settings to change this save behavior. I thing someone will face the same problem and this will be realy helpfull.
Sorry for my perseverance, but I realy still think that is a good idea
You should add the empty skins when the skeleton data loads, thereby thwarting Nate's designs.
That way, the skin will always be there and you won't need to check if it's there when you call resolveRank
. :rofl:
(But I kinda agree about the checkbox. )
Null means don't look in a skin. Using an empty skin for this seems odd, but it isn't really a big deal to allow it I guess. In 1.8.30.
I feel like rank should be an int and the returned strings should be from an array though. XD
Assuming it's Java and getUnitLevel()
returns an enum, it's as efficient as an int under the covers.