janimator0

I have a animation composed of multiple limbs which spine spits out a single texture packer image on export. Is it possible in Unity during runtime to be able to make the skeleton reference a different image of the same size and composition? Plan on doing this in order to switch skin customization's, as apposed to importing all the skin customization into spine and doing it that way. I understand that the placement and scale of the limbs will have to be similar in nature. Hopefully my question is clear.
janimator0
  • Сообщения: 5

Pharan

Yes, this is possible. I'm away from my desktop right now. I'll give you sample code a bit later.

---

Oh, were you just changing the whole skeleton's rendering from using texture1 to using texture2?
For that particular simple case, it's pretty easy.

Here's sample code for how to use MaterialPropertyBlock to achieve it.
using UnityEngine;
using System.Collections;

// This MonoBehaviour allows you to assign a Texture2D in the inspector
// and it will force the MeshRenderer to use that texture at runtime.
// This does not work when you need to use more than one texture.
public class PropertyBlockSetter : MonoBehaviour {
public Texture2D texture;

void Start () {
var mr = GetComponent<MeshRenderer>();
var propertyBlock = new MaterialPropertyBlock();
propertyBlock.SetTexture("_MainTex", texture);
mr.SetPropertyBlock(propertyBlock);
}
}


---

After you reply, we'll be moving this topic to the Spine Unity Forum
Аватара пользователя
Pharan
  • Сообщения: 5366


Вернуться в Unity