mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 17:56:04 +08:00
[ue4] Added preview skin / initial skin functionality for USpineWidget. Closes #1845.
This commit is contained in:
parent
38d8a1362a
commit
0e5d7adf1c
@ -110,7 +110,8 @@
|
|||||||
* Removed dependency on `RHI`, `RenderCore`, and `ShaderCore`.
|
* Removed dependency on `RHI`, `RenderCore`, and `ShaderCore`.
|
||||||
* Re-importing atlases and their textures now works consistently in all situations.
|
* Re-importing atlases and their textures now works consistently in all situations.
|
||||||
* Added mix-and-match example to demonstrate the new Skin API.
|
* Added mix-and-match example to demonstrate the new Skin API.
|
||||||
* Materials on `SkeletonRendererComponent` are now blueprint read and writeable. This allows setting dynamic material instances at runtime
|
* Materials on `SkeletonRendererComponent` are now blueprint read and writeable. This allows setting dynamic material instances at runtime.
|
||||||
|
* Added `InitialSkin` property to `USpineWidget`. This allows previewing different skins in the UMG Designer. Initial skins can still be overridden via blueprint events such as `On Initialized`.
|
||||||
|
|
||||||
## C# ##
|
## C# ##
|
||||||
* **Breaking changes**
|
* **Breaking changes**
|
||||||
|
|||||||
@ -99,6 +99,15 @@ void USpineWidget::SynchronizeProperties() {
|
|||||||
if (slateWidget.IsValid()) {
|
if (slateWidget.IsValid()) {
|
||||||
CheckState();
|
CheckState();
|
||||||
if (skeleton) {
|
if (skeleton) {
|
||||||
|
if (!bSkinInitialized) { // blueprint On Initialized may be called beforehand
|
||||||
|
if (InitialSkin != "") SetSkin(InitialSkin);
|
||||||
|
#if WITH_EDITOR
|
||||||
|
if (IsDesignTime()) {
|
||||||
|
if (InitialSkin == "") SetSkin("default");
|
||||||
|
bSkinInitialized = false; // allow multiple edits in editor
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
Tick(0, false);
|
Tick(0, false);
|
||||||
slateWidget->SetData(this);
|
slateWidget->SetData(this);
|
||||||
} else {
|
} else {
|
||||||
@ -204,6 +213,7 @@ bool USpineWidget::SetSkin(const FString skinName) {
|
|||||||
spine::Skin* skin = skeleton->getData()->findSkin(TCHAR_TO_UTF8(*skinName));
|
spine::Skin* skin = skeleton->getData()->findSkin(TCHAR_TO_UTF8(*skinName));
|
||||||
if (!skin) return false;
|
if (!skin) return false;
|
||||||
skeleton->setSkin(skin);
|
skeleton->setSkin(skin);
|
||||||
|
bSkinInitialized = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else return false;
|
else return false;
|
||||||
@ -222,6 +232,7 @@ bool USpineWidget::SetSkins(UPARAM(ref) TArray<FString>& SkinNames) {
|
|||||||
newSkin->addSkin(skin);
|
newSkin->addSkin(skin);
|
||||||
}
|
}
|
||||||
skeleton->setSkin(newSkin);
|
skeleton->setSkin(newSkin);
|
||||||
|
bSkinInitialized = true;
|
||||||
if (customSkin != nullptr) {
|
if (customSkin != nullptr) {
|
||||||
delete customSkin;
|
delete customSkin;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,9 @@ public:
|
|||||||
UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite)
|
||||||
float Scale = 1;
|
float Scale = 1;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Spine)
|
||||||
|
FString InitialSkin;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Spine)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Spine)
|
||||||
USpineAtlasAsset* Atlas;
|
USpineAtlasAsset* Atlas;
|
||||||
|
|
||||||
@ -256,4 +259,5 @@ private:
|
|||||||
/* If the animation should update automatically. */
|
/* If the animation should update automatically. */
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
bool bAutoPlaying;
|
bool bAutoPlaying;
|
||||||
|
bool bSkinInitialized = false;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user