Mitch




https://www.youtube.com/watch?v=W8BDM_jth3Y

Here be it! Features are now live on repo and the unity package.

<3 Pharan again
User avatar
Mitch

Mitch
Posts: 959

Nate

Very cool! :)
User avatar
Nate

Nate
Posts: 7011

davidsvson

@Mitch I love you so much! :)

Realized i needed to do exactly this. Everything is working just great!
davidsvson
Posts: 51

acorrow

Is there a way to REMOVE a sprite from code? I'm not seeing anything, but I likely missed something here. Any ideas? I basically want to attach a sprite, add an animation to the bone, and then remove it. Is this possible? Thanks!
acorrow
Posts: 3

Mitch

slot.attachment = null
User avatar
Mitch

Mitch
Posts: 959

acorrow

Thanks Mitch! Occams razor much?

I also solved this kind of on my own just now with this:

skeletonRenderer.skeleton.FindSlot(SlotName).SetToSetupPose();
acorrow
Posts: 3

davidsvson

What should i think about when i create the slots?

I'm experimenting with this but the sprites i attach usually show up rotated and/or deformed. :(

---

OK the rotation was just me forgetting to always check that the transform of the bone is always set to 0. But i can't figure out why the sprite attached show up stretched or squeezed. Any suggestions?

---

Something seems to be wrong with my sprites. I'm testing with the Spine Goblin example now and attach sprites to "left hand item" slot. Works great with the image from the goblin project. My own image gets squeezed :(

Animation looks good with dagger attached. Eye looks good
GoblinWithDagger.jpg


Eye get squeezed when attached to animation
GoblinWithEye.jpg
davidsvson
Posts: 51

Mitch



not seeing the same issue :( sorry.
User avatar
Mitch

Mitch
Posts: 959

davidsvson

Thank you, it works as it should when I use sprites from the spine library, but not when I use my own sprites, what could possibly be wrong with my sprites?

I attach one of my sprites, when I attach it to the goblin it gets deformed.

---

Finally made it!

If I change the import settings of the sprite from Mesh Type: "Tight" to "full rect" instead. It works!
davidsvson
Posts: 51

Mitch

Ah Yea. I ignored that mode for a while as unity 4 cant do it. Unity 5 has sprite features that will make mesh sprite attachments viable
User avatar
Mitch

Mitch
Posts: 959

francordoba

If I add the script to the instance on the hierarchy, work 100%, but if i add the script to the instance in the "prefab" in the folder, i have this problem...

using UnityEngine;
using System.Collections;

public class maniqui_scr : MonoBehaviour {
public Sprite sprite;

[SpineSlot]
public string slot;

void Start () {
var skeletonRenderer = GetComponent<SkeletonRenderer>();
var anadido = skeletonRenderer.skeleton.AttachUnitySprite(slot, sprite);
}
}
--> "Must have reference to a SkeletonDataAsset".

Can anybody help me?
Attachments
error_spine.jpg
francordoba
Posts: 9

Mitch

Drag prefab into scene, set properties, hit apply.
User avatar
Mitch

Mitch
Posts: 959

francordoba

The problem is that my character is instantiated with code in the runtime...i dont drag the character...
francordoba
Posts: 9

Mitch

You only have to drag it once?

The data is saved correctly even if it has an error message. Try it.
User avatar
Mitch

Mitch
Posts: 959

francordoba

Thanks, everything works but now I see that the new sprite is not moving ...
Any suggestions?
-------------
Ok, I fixed the problem, I forgot to add a slot ... :notme:

Thank you for your attention.
francordoba
Posts: 9


Return to Unity