Hi,
We've successfully managed to do the mix and match setup with various skins to build a character. However, when all skins are unequipped, the character is invisible. Is there a way to setup the default skin to show something? I can't see the default skin in the editor, and I can't create it as the name is reserved. This also leads to the character invisible in Unity and there is no skin I can choose that has all the parts. Do i need to create a "default2" skin to use? π
The other question i had was if there will be performance issues when changing skins a lot?
We have a 3 way character (up, down, side), and each direction uses a different skin combination.
Here is some pseudo code to show how we're setting it up:
// Define the cache as a dict
private Dictionary<Direction, Skin> skinCache = new Dictionary<Direction, Skin>();
// CacheSkin() method that creates a new skin on scene load, and stores it in skinCache (some code removed for clarity)
......
var skeletonData = skeletonAnimation.skeleton.Data;
var mixAndMatchSkin = new Spine.Skin("custom-chef-side");
var eyeSkin = bodySkin; //"male";
var headSkin = bodySkin; //"male";
var noseSkin = bodySkin; //"male";
var mouthSkin = bodySkin; //"male";
// Make a list of strings with all the attachments we want to copy
var skinNames = new List<string>() {
$"clothes/bottomwear/normal",
$"clothes/topwear/normal-{bodySkin}",
$"head/head-shape/{headSkin}",
$"head/hair/female", // Will only have one hair (male will be deleted)
};
foreach (var skinLabel in skinNames) {
var skin = skeletonData.FindSkin($"{skinLabel}-{direction}");
if (skin != null) {
mixAndMatchSkin.AddSkin(skin);
} else {
Debug.Log("Skin not found: " + $"{skinLabel}-{direction}");
}
}
...
// Then we use this when changing direction to get the correct skin depending on what direction we move in.
var customSkin = skinCache[CurrentDirection]
skeleton.SetSkin(customSkin)
Can you see any issue with doing it like this? Will it work even with 10-15 characters in the scene?
We've looked into the "GetRepackedSkin" features but didn't quite get it to work, but would that also help with performance?
Thanks!