nicmar

When equipping a gun it uses a modification of the mix and match script to create the weapon as attachments from sprites in Unity.

It works perfect in the Unity editor, but in a build this happens when I pick up a weapon, and all spine attachments turn into white transparent boxes.

In the video below, the "Water gun" does not use "Repack" feature, there it works, but with the shotgun it doesn't work and I get the white boxes.

Is repack important, and how do I make it work?




Here's the part of the code with comments about repack.
// STEP 3: APPLY AND CLEAN UP.
// Recommended, preferably at level-load-time: REPACK THE CUSTOM SKIN TO MINIMIZE DRAW CALLS
// IMPORTANT NOTE: the GetRepackedSkin() operation is expensive - if multiple characters
// need to call it every few seconds the overhead will outweigh the draw call benefits.
//
// Repacking requires that you set all source textures/sprites/atlases to be Read/Write enabled in the inspector.
// Combine all the attachment sources into one skin. Usually this means the default skin and the custom skin.
// call Skin.GetRepackedSkin to get a cloned skin with cloned attachments that all use one texture.

if (repack) {
var repackedSkin = new Skin("repacked skin");
repackedSkin.AddSkin(skeleton.Data.DefaultSkin); // Include the "default" skin. (everything outside of skin placeholders)
repackedSkin.AddSkin(customSkin); // Include your new custom skin.
if (runtimeMaterial)
Destroy(runtimeMaterial);
if (runtimeAtlas)
Destroy(runtimeAtlas);
repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas); // Pack all the items in the skin.
skeleton.SetSkin(repackedSkin); // Assign the repacked skin to your Skeleton.
if (bbFollower != null) bbFollower.Initialize(true);
} else {
skeleton.SetSkin(customSkin); // Just use the custom skin directly.
}
Thank you!
You do not have the required permissions to view the files attached to this post.
We're making SpaceChef with Spine. An action filled cooking adventure. We're coming soon to Kickstarter, sign up for our newsletter to be the first to get notified: www.spacechefgame.com. Follow our work on Twitter @BlueGooGames.
User avatar
nicmar
  • Posts: 128

Harald

Sorry to hear you're having troubles. Most likely the read/write enabled or texture compression settings of the texture are setup incorrectly for reading the texture. Did you check the list of common causes for repacking to fail on the spine-unity docs pages here (section Runtime Repacking, Important Note)?
User avatar
Harald

Harri
  • Posts: 3575

nicmar

Thank you for responding! Sorry for not getting back, I will check this next time it happens :)

-niclas
We're making SpaceChef with Spine. An action filled cooking adventure. We're coming soon to Kickstarter, sign up for our newsletter to be the first to get notified: www.spacechefgame.com. Follow our work on Twitter @BlueGooGames.
User avatar
nicmar
  • Posts: 128


Return to Unity