- 수정됨
[spine-unity]스킨 호출 시 리소스 튀는 현상
안녕하세요.
스파인 유니티 환경에서 스킨 호출 시 리소스가 튀는 현상이 있어 문의드립니다.
개발 환경은 다음과 같습니다.
유니티 2021.3.7f1
스파인 런타임 4
스파인 에디터 4.0.64
커맨드 입력을 받아 스킨 변경을 호출 받아 업데이트하는 형식입니다.
문제는 매번 스킨을 호출 할 때마다 리소스가 비정상적으로 튀는 현상이 발생합니다.
스파인 에디터, 스켈레톤 뷰어에서 스킨 변경 시 문제 사항이 없습니다.
하지만 내부 프로젝트 유니티 환경에서 스킨 호출 시 문제가 발생됩니다. :tear:
예시로 스파인보이 샘플의 경우 캐릭터 오른팔 슬롯에 있는 "front-fist-open", "front-fist-closed" 이미지가 튀면서 렌더링됩니다. 추가로 해당 이미지는 스킨 할당이 없는 디폴트 상태입니다.
아래는 개발 담당 프로그래머분께서 공유주신 코드입니다.
public void SetFace(string faceName)
{
if (this.m_skelAnim == null)
this.m_skelAnim = this.gameObject.GetComponent<SkeletonAnimation>();
if (this.m_skielAnim_UI == null)
this.m_skielAnim_UI = this.gameObject.GetComponent<SkeletonGraphic>();
if (this.m_skelAnim == null && this.m_skielAnim_UI == null)
return;
if (this.m_skelAnim != null)
{
var skeletonAnimation = m_skelAnim;
var skeleton = skeletonAnimation.Skeleton;
var skeletonData = skeleton.Data;
var resultCombinedSkin = new Spine.Skin("character-combined");
var characterSkin = new Spine.Skin("character-base");
characterSkin.AddSkin(skeleton.Data.FindSkin(faceName));
resultCombinedSkin.AddSkin(characterSkin);
skeleton.SetSkin(resultCombinedSkin);
skeleton.SetSlotsToSetupPose();
}
if (this.m_skielAnim_UI != null)
{
var skeletonAnimation = m_skielAnim_UI;
var skeleton = skeletonAnimation.Skeleton;
var skeletonData = skeleton.Data;
var resultCombinedSkin = new Spine.Skin("character-combined");
var characterSkin = new Spine.Skin("character-base");
characterSkin.AddSkin(skeleton.Data.FindSkin(faceName));
resultCombinedSkin.AddSkin(characterSkin);
skeleton.SetSkin(resultCombinedSkin);
skeleton.SetSlotsToSetupPose();
}
}
참고 영상 유튜브 링크
https://youtube.com/shorts/NgKFOcUH1os?feature=share
기계 번역이 다소 모호한 결과를 제공했기 때문에 문제를 올바르게 이해했는지 잘 모르겠습니다. SetFace
메서드를 호출한 후 한 프레임에 대해 닫힌 주먹 부착물(설정 포즈에서)이 보인다는 뜻인가요?
이것이 문제라면 'SetFace' 메서드가 업데이트 순서에서 너무 늦게 호출되었을 가능성이 있습니다. 애니메이션을 적용한 SkeletonAnimation.Update
이후에 호출되어 그에 따라 활성 첨부 파일을 설정합니다. 어디에서 SetFace
를 호출하고 있습니까? 일반적으로 다음 중 하나를 수행해야 합니다.
a) SkeletonAnimation.Update
가 호출되기 전에 SetFace
를 호출해야 합니다. 또는
b) SetSlotsToSetupPose
뒤에 다음 호출을 추가합니다.
skeletonAnimation.AnimationState.Apply(skeletonAnimation.Skeleton);
후자는 Mix and Match Skins
예제 장면에서 사용되는 MixAndMatchSkinsExample.cs
예제 스크립트에서도 실제로 볼 수 있습니다.
I'm not sure I understand your problem correctly, as machine translation has provided a rather ambiguous result. Do you mean that you see the closed fist attachment (from setup pose) for one frame after calling your SetFace
method?
If this is your problem, then the issue is likely that your SetFace
method is called too late in the update order, e.g. called after SkeletonAnimation.Update
which applied the animation, setting active attachments accordingly. From where are you calling SetFace
? In general you need to either
a) make sure to call SetFace
before SkeletonAnimation.Update
is called, or
b) add the following call after SetSlotsToSetupPose
:
skeletonAnimation.AnimationState.Apply(skeletonAnimation.Skeleton);
The latter can also be seen in action in the MixAndMatchSkinsExample.cs
example script that is used in the Mix and Match Skins
example scene.
답변 주셔서 감사합니다.
업데이트 순서에 따른 해결 가능성이 있는거군요.
해당 내용을 개발 담당 클라이언트에 전달하여 해결 가능한지 체크해보겠습니다.
좋은 결과 가져오도록 하겠습니다.
정상적으로 해결되었습니다.
이제 우리가 원하던 결과가 나오게 되었네요. 감사합니다!
문제가 해결되어 매우 기쁩니다. 알려주셔서 감사합니다!
Very glad to hear it resolved your issue. Thanks for letting us know!