Hi Pharan,
Thanks again for your help. I didn't notice that the height and width were 0, I only looked at RegionHeight and RegionWidth, and you are right, it should be expected that they would be invisible under those circumstances. It's actually kind of weird though that they have to be set when RegionHeight and RegionWidth are set to the size of the sprite. Why is that?
As for UpdateOffset, I was calling it. I omitted it in the post for brevity's sake. This time I'm going to copy the exact code.
public tk2dSpriteCollectionData DataCollectionSpriteTK2D;
public String NameSlotSkeletonSpineEquipmentHandLeft;
private Spine.Unity.SkeletonAnimation _animationSkeletonUnitySpine;
private Int32 _indexSlotSkeletonSpineEquipmentHandLeft;
private Spine.Unity.TK2D.SpriteCollectionAttachmentLoader _loaderAttachmentCollectionSpriteTK2DUnitySpine;
private Spine.Skeleton _skeletonSpine;
private Spine.AnimationState _stateAnimationSpine;
private void Awake()
{
_animationSkeletonUnitySpine = GetComponent<Spine.Unity.SkeletonAnimation>();
_loaderAttachmentCollectionSpriteTK2DUnitySpine = new SpriteCollectionAttachmentLoader(DataCollectionSpriteTK2D);
_skeletonSpine = _animationSkeletonUnitySpine.Skeleton;
_stateAnimationSpine = _animationSkeletonUnitySpine.AnimationState;
}
private RegionAttachment NewRegionAttachmentFromSpriteCollection(String nameSpriteTK2D)
{
RegionAttachment attachmentRegionCollectionSprite =
_loaderAttachmentCollectionSpriteTK2DUnitySpine.NewRegionAttachment(null,
nameSpriteTK2D,
nameSpriteTK2D);
attachmentRegionCollectionSprite.X = 0;
attachmentRegionCollectionSprite.Y = 0;
attachmentRegionCollectionSprite.ScaleX = 1;
attachmentRegionCollectionSprite.ScaleY = 1;
attachmentRegionCollectionSprite.Rotation = 0;
attachmentRegionCollectionSprite.Height = attachmentRegionCollectionSprite.RegionHeight;
attachmentRegionCollectionSprite.Width = attachmentRegionCollectionSprite.RegionWidth;
attachmentRegionCollectionSprite.R = 1;
attachmentRegionCollectionSprite.G = 1;
attachmentRegionCollectionSprite.B = 1;
attachmentRegionCollectionSprite.A = 1;
attachmentRegionCollectionSprite.UpdateOffset();
return attachmentRegionCollectionSprite;
}
private void Start()
{
RegionAttachment attachmentRegionDagger = NewRegionAttachmentFromSpriteCollection("Wpn-Dagger");
_indexSlotSkeletonSpineEquipmentHandLeft = SkeletonSpine.FindSlotIndex(NameSlotSkeletonSpineEquipmentHandLeft);
_skeletonSpine.Skin.AddAttachment(_indexSlotSkeletonSpineEquipmentHandLeft,
"Eqpmnt-Hnd-Lft",
attachmentRegionDagger);
}
The sprite still does not show up. Here are the updated properties with Height and Width set.
- attachmentRegionDagger "Wpn-Dagger" Spine.RegionAttachment
- base "Wpn-Dagger" Spine.Attachment
A 1 System.Single
B 1 System.Single
G 1 System.Single
Height 500 System.Single
- Offset System.Single[8] System.Single[]
[0] -51 System.Single
[1] -250 System.Single
[2] -51 System.Single
[3] 250 System.Single
[4] 51 System.Single
[5] 250 System.Single
[6] 51 System.Single
[7] -250 System.Single
Path "Wpn-Dagger" System.String
R 1 System.Single
RegionHeight 500 System.Single
RegionOffsetX 0 System.Single
RegionOffsetY 0 System.Single
RegionOriginalHeight 500 System.Single
RegionOriginalWidth 102 System.Single
RegionWidth 102 System.Single
- RendererObject "Weapons-SpriteAtlasMaterial (UnityEngine.Material)" System.Object
Rotation 0 System.Single
ScaleX 1 System.Single
ScaleY 1 System.Single
- UVs System.Single[8] System.Single[]
Width 102 System.Single
X 0 System.Single
Y 0 System.Single
a 1 System.Single
b 1 System.Single
g 1 System.Single
height 500 System.Single
- offset System.Single[8] System.Single[]
r 1 System.Single
regionHeight 500 System.Single
regionOffsetX 0 System.Single
regionOffsetY 0 System.Single
regionOriginalHeight 500 System.Single
regionOriginalWidth 102 System.Single
regionWidth 102 System.Single
rotation 0 System.Single
scaleX 1 System.Single
scaleY 1 System.Single
- uvs System.Single[8] System.Single[]
width 102 System.Single
x 0 System.Single
y 0 System.Single
- Static members
At this point, I'm looking at everything. I can spawn a Dagger sprite (one that I can see) from the SpriteCollection into the scene. So I think the SpriteCollection is functioning correctly. I'm wondering if the problem could be with the Spine file.
How should we proceed at this point?
Thanks,
-n3xes