mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +08:00
[ue4] Added blueprint node for SpineWidget and SpineSkeletonComponent. Expects an array of skin names. Creates a new spine::Skin internally from those skins and applies it to the skeleton. Closes #1416, closes #1534.
This commit is contained in:
parent
c9d871ab63
commit
c0699e23a0
@ -41,6 +41,28 @@ USpineSkeletonComponent::USpineSkeletonComponent () {
|
|||||||
bAutoActivate = true;
|
bAutoActivate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool USpineSkeletonComponent::SetSkins(UPARAM(ref) TArray<FString>& SkinNames) {
|
||||||
|
CheckState();
|
||||||
|
if (skeleton) {
|
||||||
|
spine::Skin* newSkin = new spine::Skin("__spine-ue3_custom_skin");
|
||||||
|
for (auto& skinName : SkinNames) {
|
||||||
|
spine::Skin* skin = skeleton->getData()->findSkin(TCHAR_TO_UTF8(*skinName));
|
||||||
|
if (!skin) {
|
||||||
|
delete newSkin;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
newSkin->addSkin(skin);
|
||||||
|
}
|
||||||
|
skeleton->setSkin(newSkin);
|
||||||
|
if (customSkin != nullptr) {
|
||||||
|
delete customSkin;
|
||||||
|
}
|
||||||
|
customSkin = newSkin;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool USpineSkeletonComponent::SetSkin (const FString skinName) {
|
bool USpineSkeletonComponent::SetSkin (const FString skinName) {
|
||||||
CheckState();
|
CheckState();
|
||||||
if (skeleton) {
|
if (skeleton) {
|
||||||
|
|||||||
@ -185,6 +185,11 @@ void USpineWidget::DisposeState() {
|
|||||||
skeleton = nullptr;
|
skeleton = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (customSkin) {
|
||||||
|
delete customSkin;
|
||||||
|
customSkin = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
trackEntries.Empty();
|
trackEntries.Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,6 +209,28 @@ bool USpineWidget::SetSkin(const FString skinName) {
|
|||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool USpineWidget::SetSkins(UPARAM(ref) TArray<FString>& SkinNames) {
|
||||||
|
CheckState();
|
||||||
|
if (skeleton) {
|
||||||
|
spine::Skin* newSkin = new spine::Skin("__spine-ue3_custom_skin");
|
||||||
|
for (auto& skinName : SkinNames) {
|
||||||
|
spine::Skin* skin = skeleton->getData()->findSkin(TCHAR_TO_UTF8(*skinName));
|
||||||
|
if (!skin) {
|
||||||
|
delete newSkin;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
newSkin->addSkin(skin);
|
||||||
|
}
|
||||||
|
skeleton->setSkin(newSkin);
|
||||||
|
if (customSkin != nullptr) {
|
||||||
|
delete customSkin;
|
||||||
|
}
|
||||||
|
customSkin = newSkin;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
void USpineWidget::GetSkins(TArray<FString> &Skins) {
|
void USpineWidget::GetSkins(TArray<FString> &Skins) {
|
||||||
CheckState();
|
CheckState();
|
||||||
if (skeleton) {
|
if (skeleton) {
|
||||||
|
|||||||
@ -56,6 +56,9 @@ public:
|
|||||||
UFUNCTION(BlueprintPure, Category = "Components|Spine|Skeleton")
|
UFUNCTION(BlueprintPure, Category = "Components|Spine|Skeleton")
|
||||||
void GetSkins(TArray<FString> &Skins);
|
void GetSkins(TArray<FString> &Skins);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
|
||||||
|
bool SetSkins(UPARAM(ref) TArray<FString>& SkinNames);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
|
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
|
||||||
bool SetSkin (const FString SkinName);
|
bool SetSkin (const FString SkinName);
|
||||||
|
|
||||||
@ -139,4 +142,5 @@ protected:
|
|||||||
USpineAtlasAsset* lastAtlas = nullptr;
|
USpineAtlasAsset* lastAtlas = nullptr;
|
||||||
spine::Atlas* lastSpineAtlas = nullptr;
|
spine::Atlas* lastSpineAtlas = nullptr;
|
||||||
USpineSkeletonDataAsset* lastData = nullptr;
|
USpineSkeletonDataAsset* lastData = nullptr;
|
||||||
|
spine::Skin* customSkin = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -89,6 +89,9 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
|
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
|
||||||
bool SetSkin(const FString SkinName);
|
bool SetSkin(const FString SkinName);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
|
||||||
|
bool SetSkins(UPARAM(ref) TArray<FString> &SkinNames);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
|
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
|
||||||
bool HasSkin(const FString SkinName);
|
bool HasSkin(const FString SkinName);
|
||||||
|
|
||||||
@ -222,6 +225,7 @@ protected:
|
|||||||
USpineAtlasAsset* lastAtlas = nullptr;
|
USpineAtlasAsset* lastAtlas = nullptr;
|
||||||
spine::Atlas* lastSpineAtlas = nullptr;
|
spine::Atlas* lastSpineAtlas = nullptr;
|
||||||
USpineSkeletonDataAsset* lastData = nullptr;
|
USpineSkeletonDataAsset* lastData = nullptr;
|
||||||
|
spine::Skin* customSkin = nullptr;
|
||||||
|
|
||||||
// Need to hold on to the dynamic instances, or the GC will kill us while updating them
|
// Need to hold on to the dynamic instances, or the GC will kill us while updating them
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user