When I GetRepackedSkin,i had a error.
Graphics.CopyTexture could not find destination D3D11 texture object. Maybe it is a RenderTexture that is not created yet?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Spine.Unity;
using Spine.Unity.AttachmentTools;
public class TestSpine : MonoBehaviour
{
public SkeletonAnimation blackbear;
public SkeletonAnimation greenbear;
private Material _runtimeMaterial;
private Texture2D _runtimeAtlas;
void Start()
{
StartCoroutine(ChangeSkin());
}
IEnumerator ChangeSkin()
{
yield return new WaitForEndOfFrame();
greenbear.gameObject.SetActive(false);
yield return new WaitForSeconds(3f);
Spine.Skin SkinDefault = blackbear.skeleton.Data.FindSkin("_Default");
Spine.Skin Skinhead = greenbear.skeleton.Data.FindSkin("hat");
Spine.Skin skinMix = new Spine.Skin("Mix");
skinMix.CopySkin(SkinDefault);
skinMix.AddSkin(Skinhead);
blackbear.skeleton.SetSkin(skinMix);
blackbear.skeleton.UpdateCache();
blackbear.skeleton.SetSlotsToSetupPose();
if (null != _runtimeMaterial)
{
Destroy(_runtimeMaterial);
}
if (null != _runtimeAtlas)
{
Destroy(_runtimeAtlas);
}
Spine.Skin repackedSkin = skinMix.GetRepackedSkin(
"RepackedSkin",
blackbear.skeletonDataAsset.atlasAssets[0].PrimaryMaterial,
out _runtimeMaterial,
out _runtimeAtlas
);
skinMix.Clear();
blackbear.skeleton.SetSkin(repackedSkin);
blackbear.skeleton.UpdateCache();
blackbear.skeleton.SetSlotsToSetupPose();
Destroy(greenbear.gameObject);
}
}