Cranktrain

Hi, I've just performed a long overdue upgrade from 3.6 to 3.8, and it was a successful upgrade, all my re-exported Spine characters work great.

With just one exception - there's one Spine skeleton where I need to repack the Skin at runtime, but there's some problem with the material, the atlas, and how the bounds for each slot get calculated.

Here's what the error looks like.

My repacking code is pretty much the same as it is in the docs:
// The image exported from Spine needs to have Read/Write enabled:
Material runtimeMaterial;
Texture2D runtimeAtlas;
workingSkin = workingSkin.GetRepackedSkin("WorkingSkin", spineAnimator.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial, out runtimeMaterial, out runtimeAtlas);
AtlasUtilities.ClearCache();

spineAnimator.skeleton.skin = workingSkin;
spineAnimator.skeleton.SetSlotsToSetupPose();
spineAnimator.Update();
If I comment all that out, my character displays fine! There's something that happens when I repack that fails in 3.8 where it was working in 3.6.

Is there some setting when I export from Spine that I need to get right in this newer Spine version? Or is it a setting on the Texture Import Settings in Unity that needs to match up?
Hình đại diện của thành viên
Cranktrain
  • Bài viết: 64

Harald

Sorry for the trouble! Could you please send us a minimal Unity project that still demonstrates the issue as a zip package (also please include the problematic Spine project), to contact@esotericsoftware.com. Then we can have a look at what's going wrong here.
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 1951

Cranktrain

Thanks Harald, I've just emailed you a stripped-down Unity project that reproduces my issue, along with the Spine character project too.
Hình đại diện của thành viên
Cranktrain
  • Bài viết: 64

Harald

Thanks for sending the repro project, we received everything. We will get back to you as soon as we have figured out what's going wrong.

---

The problem is that your exported atlas texture human2 is not a power of two in size (2001x1873 px), then you have to set the Texture import setting Advanced - Non-Power of 2 to None to make repacking work (it is set to ToNearest by default). Otherwise Unity accesses incorrectly offset regions of the texture when copying parts to the repacked texture (I would actually consider this a bug on Unity's side).

In general in your case it would be best to export a power-of-two atlas image from Spine right away (no need to be square though).
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 1951

Cranktrain

Thanks Harald, I'm afraid I'm still having some Graphics.CopyTexture errors, complaining that Graphics.CopyTexture can only copy memory with the same size. I can't spot where I'm going wrong.

Here's my Spine export settings (Power of two now ticked!):



Here's the human2.png texture Import settings (Non-Power of 2 is None, the size is 2048):



And my code now reads:
Material runtimeMaterial;
Texture2D runtimeAtlas;
workingSkin = workingSkin.GetRepackedSkin("WorkingSkin", spineAnimator.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial, out runtimeMaterial, out runtimeAtlas, 2048); // Now specifying 2048
AtlasUtilities.ClearCache();
I can't spot what I'm missing, everything is referencing 2048x2048, and a square?
Hình đại diện của thành viên
Cranktrain
  • Bài viết: 64

Harald

While the error description is a bit misleading, I think that the problem is that you are copying from a compressed texture (Compression = Normal Quality) to a non-compressed RGBA texture. So I guess it should work when you change Compression to None in the Texture importer settings.
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 1951

Cranktrain

You were absolutely correct that setting Compression to None fixes those specific error messages, thanks for that. But sadly, after making that change I still end up with this:



No errors or warnings in the console whatsoever.

I've double-checked everything is still as it was in my reply to this thread yesterday: a power of 2, square 2048x2048 image, and I specify 2048 when I call GetRepackedSkin. I seem to be back to square one!
Hình đại diện của thành viên
Cranktrain
  • Bài viết: 64

Harald

Did you perhaps change to Quality settings where Texture resolution is not full-res but half or quarter resolution? This is a known Unity bug unfortunately.
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 1951

Cranktrain

:O There it is. Going to the Unity Project Settings I found my Texture Resolution is set to half, thanks for catching that Harald, sorry to hear it's a Unity bug.

Appreciate your help very much!

One last minor suggestion; would some of this information fit in the 'Runtime Repacking' section of the Combining Skins docs? Things like not supporting Quality Settings of non-full res textures, and needing a power of 2 texture size from spine or setting non-power-of-2 to None in the texture import settings, that sort of thing?
Hình đại diện của thành viên
Cranktrain
  • Bài viết: 64

Harald

You are absolutely right, thanks for the reminder! :) I have just added a note section listing all known causes:
spine-unity Runtime Documentation: Combining Skins
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 1951


Quay về Unity