mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +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`.
|
||||
* Re-importing atlases and their textures now works consistently in all situations.
|
||||
* 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# ##
|
||||
* **Breaking changes**
|
||||
|
||||
@ -99,6 +99,15 @@ void USpineWidget::SynchronizeProperties() {
|
||||
if (slateWidget.IsValid()) {
|
||||
CheckState();
|
||||
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);
|
||||
slateWidget->SetData(this);
|
||||
} else {
|
||||
@ -204,6 +213,7 @@ bool USpineWidget::SetSkin(const FString skinName) {
|
||||
spine::Skin* skin = skeleton->getData()->findSkin(TCHAR_TO_UTF8(*skinName));
|
||||
if (!skin) return false;
|
||||
skeleton->setSkin(skin);
|
||||
bSkinInitialized = true;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
@ -222,6 +232,7 @@ bool USpineWidget::SetSkins(UPARAM(ref) TArray<FString>& SkinNames) {
|
||||
newSkin->addSkin(skin);
|
||||
}
|
||||
skeleton->setSkin(newSkin);
|
||||
bSkinInitialized = true;
|
||||
if (customSkin != nullptr) {
|
||||
delete customSkin;
|
||||
}
|
||||
|
||||
@ -53,6 +53,9 @@ public:
|
||||
UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite)
|
||||
float Scale = 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Spine)
|
||||
FString InitialSkin;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Spine)
|
||||
USpineAtlasAsset* Atlas;
|
||||
|
||||
@ -256,4 +259,5 @@ private:
|
||||
/* If the animation should update automatically. */
|
||||
UPROPERTY()
|
||||
bool bAutoPlaying;
|
||||
bool bSkinInitialized = false;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user