public void OptimizeSkin() { // 1. Collect all the attachments of all active skins. collectedSkin = collectedSkin ?? new Skin("Collected skin"); collectedSkin.Clear(); collectedSkin.Append(skeletonAnimation.Skeleton.Data.DefaultSkin); collectedSkin.Append(equipsSkin); // 2. Create a repacked skin. var repackedSkin = collectedSkin.GetRepackedSkin("Repacked skin", skeletonAnimation.SkeletonDataAsset.atlasAssets[0].materials[0], out runtimeMaterial, out runtimeAtlas); collectedSkin.Clear(); // 3. Use the repacked skin. skeletonAnimation.Skeleton.Skin = repackedSkin; RefreshSkeletonAttachments(); skeletonAnimation.OverrideTexture = runtimeAtlas; }
void Start() { equipsSkin = new Skin("Equips"); // OPTIONAL: Add all the attachments from the template skin. var templateSkin = skeletonAnimation.Skeleton.Data.FindSkin(templateSkinName); if (templateSkin != null) { equipsSkin.Append(templateSkin); } skeletonAnimation.Skeleton.Skin = equipsSkin; RefreshSkeletonAttachments(); }