Ah, let me clarify...
I am not using real lighting, this is just a flipped and skewed mesh. What I am really asking is...
Is there there a way to change the Skeletons Alpha as one piece to avoid the overlaps.
No ideas?
Ah, let me clarify...
I am not using real lighting, this is just a flipped and skewed mesh. What I am really asking is...
Is there there a way to change the Skeletons Alpha as one piece to avoid the overlaps.
No ideas?
Awesome, thanks @Pharan its all working now with the 1 material
I went for method B
The step I was missing was I appended the default skins to the Custom Skin, thinking it would transfer and NOT the repacked skin. Something like this.
PSUEDO(ish) code
Skin pSkin = new Skin("Custom Skin");
pSkin.Append(_Skel.Data.DefaultSkin);
pSkin.Append(_Skel.Data.FindSkin(m_BaseSkin));
//DO ALL MY ATTACHING
Skin repackedSkin = new Skin(skinName);
// ADDED THESE 2 LINES to Fix the material issue.
repackedSkin.Append(_Skel.Data.DefaultSkin);
repackedSkin.Append(_Skel.Data.FindSkin(m_BaseSkin));
//
repackedSkin.Append(pSkin); // Include your new custom skin.
repackedSkin = repackedSkin.GetRepackedSkin(skinName, _mat, out runtimeMaterial, out runtimeAtlas); // Pack all the items in the skin.
I assume I am doing something wrong here?
It seems to create multiple materials, with duplicate sprites in them, as opposed to one complete material.
PSEUDO(ish) CODE
Skin pSkin = new Skin("Custom Skin");
pSkin.Append(_Skel.Data.FindSkin(m_BaseSkin));
... DO Attachments
Texture2D runtimeAtlas;
Material runtimeMaterial;
skinCount++;
string skinName = "NEW Skin " + skinCount.ToString();
var repackedSkin = new Skin(skinName);
repackedSkin.Append(pSkin); // Include your new custom skin.
repackedSkin = pSkin.GetRepackedSkin(skinName, _mat, out runtimeMaterial, out runtimeAtlas); // Pack all the items in the skin.
SkeletonGraphic pGraphic = _Character.GetComponent<SkeletonGraphic>();
if (pGraphic)
{
pGraphic.OverrideTexture = null;
pGraphic.OverrideTexture = runtimeAtlas;
}
_Skel.SetSkin(repackedSkin); // Assign the repacked skin to your Skeleton.
runtimeAtlas = null;
runtimeMaterial = null;
repackedSkin = null;
You can repro this by changing the MixAndMatch demo
MixAndMatch line: 121
//repackedSkin.Append(skeleton.Data.DefaultSkin); // Include the "default" skin. (everything outside of skin placeholders)
repackedSkin.Append(skeleton.Data.FindSkin("base"));
It will then use two materials for SpineBoy, as opposed to one consolidated material.
I could probably solve my issue by using the default skin in the Spine Editor, but I have no way to Set my default skin, and all its information is blank (been using this rig for multiple editor updates)
Hi,
Is there any way to render the Skeleton as one, so I can create a FAKE shadow without this issue? (flipped and skewed sprite)
Or any other ideas, shaders etc?
Awesome, works perfectly.
Thanks @Pharan
But when I override with a new attachment, it doesn't release the old texture, it stays in memory forever.
I've tried setting the attachment to null, before setting the new one, but that had no affect.
Hello,
I appear to be getting some kind of texture leak when using.
newSprite = pAttachment.GetRemappedClone(aSprite, _mat);
if (newSprite != null)
{
_Skin.SetAttachment(slotIndex, skeyname, newSprite);
}
It only occurs if i do setAttachment, does setattachment release its references?
Hello,
Would it be possible to get a version of SetSlotsToSetupPose() that does not reset the Tint of the Slot?
Normally I just want to reset the attachments, but not the overridden colour of the attachments.
Thanks
thanks guys.
I've just stuck it into an extension method library for now, hopefully it'll make the official runtimes sometime.
For you copy pasters...
static class spineExtensions
{
public static void setAttachmentsToSetupPose(this Skeleton _Skeleton)
{
//Reset Draw Order
var slots = _Skeleton.slots;
var slotsItems = slots.Items;
_Skeleton.drawOrder.Clear();
for (int i = 0, n = slots.Count; i < n; i++)
_Skeleton.drawOrder.Add(slotsItems[i]);
//Reset Attachments
foreach (Slot s in _Skeleton.Slots)
{
SlotData data = s.Data;
if (data.attachmentName == null)
{
s.Attachment = null;
}
else
{
s.attachment = null;
s.Attachment = _Skeleton.GetAttachment(data.index, data.attachmentName);
}
}
}
}
@Pharan just to clarify
I am asking could we have an option to not reset the colours.
I only want to reset the attachment image, but not the colour.
my example above was just to show a simple way to implement this
I am suggesting it uses a default argument (set to true to keep the current behaviour)
@badlogic the default parameter means it doesn't require any updates from anyone
Hello,
Is there a version of SetSlotsToSetupPose() which doesn't reset the Colours of the Slots?
If not, could there be? Whilst I can add this myself, official runtime support would be great.
e.g SetSlotsToSetupPose(bool _resetColour=true)
Thanks!
I've managed to solve the issue.
Attached Sprites must be set to 'Full Rect' or it will create a packing error.
Loading Image
Hello,
I am getting this error when repacking my skins. Skins work fine when the are not repacked.
Texture rectangle is out of bounds (0 + 173 > 162)
UnityEngine.Texture2D:GetPixels(Int32, Int32, Int32, Int32)
Spine.Unity.Modules.AttachmentTools.SpriteAtlasRegionExtensions:ToTexture(AtlasRegion, Boolean, TextureFormat, Boolean) (at Assets/Spine/spine-unity/Modules/AttachmentTools/AttachmentTools.cs:509)
Spine.Unity.Modules.AttachmentTools.SpriteAtlasRegionExtensions:GetRepackedSkin(Skin, String, Shader, Material&, Texture2D&, Int32, Int32, TextureFormat, Boolean, Material) (at Assets/Spine/spine-unity/Modules/AttachmentTools/AttachmentTools.cs:429)
Spine.Unity.Modules.AttachmentTools.SpriteAtlasRegionExtensions:GetRepackedSkin(Skin, String, Material, Material&, Texture2D&, Int32, Int32, TextureFormat, Boolean) (at Assets/Spine/spine-unity/Modules/AttachmentTools/AttachmentTools.cs:400)
Any ideas?