mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[ue4] Updated example project to 4.20. Fixed re-import of skeletons, see #1177.
This commit is contained in:
parent
0e6673c370
commit
b2479bf7bf
Binary file not shown.
@ -51,7 +51,7 @@ USpineAtlasAssetFactory::USpineAtlasAssetFactory (const FObjectInitializer& obje
|
||||
bEditorImport = true;
|
||||
SupportedClass = USpineAtlasAsset::StaticClass();
|
||||
|
||||
Formats.Add(TEXT("atlas;Spine atlas file"));
|
||||
Formats.Add(TEXT("atlas;Spine Atlas file"));
|
||||
}
|
||||
|
||||
FText USpineAtlasAssetFactory::GetToolTip () const {
|
||||
|
||||
@ -6,9 +6,11 @@ namespace UnrealBuildTool.Rules
|
||||
{
|
||||
public SpineEditorPlugin(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PublicIncludePaths.AddRange(new string[] { "SpineEditorPlugin/Public", "SpinePlugin/Public/spine-cpp/include" });
|
||||
|
||||
PrivateIncludePaths.AddRange(new string[] { "SpineEditorPlugin/Private", "SpinePlugin/Public/spine-cpp/include" });
|
||||
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Public"));
|
||||
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "../SpinePlugin/Public/spine-cpp/include"));
|
||||
|
||||
PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "Public"));
|
||||
PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "../SpinePlugin/Public/spine-cpp/include"));
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] {
|
||||
"Core",
|
||||
@ -17,12 +19,12 @@ namespace UnrealBuildTool.Rules
|
||||
"UnrealEd",
|
||||
"SpinePlugin"
|
||||
});
|
||||
|
||||
|
||||
PublicIncludePathModuleNames.AddRange(new string[] {
|
||||
"AssetTools",
|
||||
"AssetRegistry"
|
||||
});
|
||||
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(new string[] {
|
||||
"AssetTools",
|
||||
"AssetRegistry"
|
||||
|
||||
@ -111,7 +111,7 @@ Atlas* USpineAtlasAsset::GetAtlas (bool ForceReload) {
|
||||
page->setRendererObject(atlasPages[j++]);
|
||||
}
|
||||
}
|
||||
return this->atlas;
|
||||
return this->atlas;
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
@ -104,11 +104,27 @@ void USpineSkeletonAnimationComponent::InternalTick(float DeltaTime, bool CallDe
|
||||
}
|
||||
|
||||
void USpineSkeletonAnimationComponent::CheckState () {
|
||||
if (lastAtlas != Atlas || lastData != SkeletonData) {
|
||||
bool needsUpdate = lastAtlas != Atlas || lastData != SkeletonData;
|
||||
|
||||
if (!needsUpdate) {
|
||||
// Are we doing a re-import? Then check if the underlying spine-cpp data
|
||||
// has changed.
|
||||
if (lastAtlas && lastAtlas == Atlas && lastData && lastData == SkeletonData) {
|
||||
spine::Atlas* atlas = Atlas->GetAtlas(false);
|
||||
if (lastSpineAtlas != atlas) {
|
||||
needsUpdate = true;
|
||||
}
|
||||
if (skeleton && skeleton->getData() != SkeletonData->GetSkeletonData(atlas)) {
|
||||
needsUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
DisposeState();
|
||||
|
||||
if (Atlas && SkeletonData) {
|
||||
spine::SkeletonData *data = SkeletonData->GetSkeletonData(Atlas->GetAtlas(false), false);
|
||||
spine::SkeletonData *data = SkeletonData->GetSkeletonData(Atlas->GetAtlas(false), true);
|
||||
if (data) {
|
||||
skeleton = new (__FILE__, __LINE__) Skeleton(data);
|
||||
AnimationStateData* stateData = SkeletonData->GetAnimationStateData(Atlas->GetAtlas(false));
|
||||
@ -120,6 +136,7 @@ void USpineSkeletonAnimationComponent::CheckState () {
|
||||
}
|
||||
|
||||
lastAtlas = Atlas;
|
||||
lastSpineAtlas = Atlas ? Atlas->GetAtlas(false) : nullptr;
|
||||
lastData = SkeletonData;
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +200,23 @@ void USpineSkeletonComponent::InternalTick(float DeltaTime, bool CallDelegates)
|
||||
}
|
||||
|
||||
void USpineSkeletonComponent::CheckState () {
|
||||
if (lastAtlas != Atlas || lastData != SkeletonData) {
|
||||
bool needsUpdate = lastAtlas != Atlas || lastData != SkeletonData;
|
||||
|
||||
if (!needsUpdate) {
|
||||
// Are we doing a re-import? Then check if the underlying spine-cpp data
|
||||
// has changed.
|
||||
if (lastAtlas && lastAtlas == Atlas && lastData && lastData == SkeletonData) {
|
||||
spine::Atlas* atlas = Atlas->GetAtlas(false);
|
||||
if (lastSpineAtlas != atlas) {
|
||||
needsUpdate = true;
|
||||
}
|
||||
if (skeleton && skeleton->getData() != SkeletonData->GetSkeletonData(atlas)) {
|
||||
needsUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
DisposeState();
|
||||
|
||||
if (Atlas && SkeletonData) {
|
||||
@ -209,6 +225,7 @@ void USpineSkeletonComponent::CheckState () {
|
||||
}
|
||||
|
||||
lastAtlas = Atlas;
|
||||
lastSpineAtlas = Atlas ? Atlas->GetAtlas(false) : nullptr;
|
||||
lastData = SkeletonData;
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ void USpineSkeletonDataAsset::BeginDestroy () {
|
||||
}
|
||||
|
||||
SkeletonData* USpineSkeletonDataAsset::GetSkeletonData (Atlas* Atlas, bool ForceReload) {
|
||||
if (!skeletonData || ForceReload) {
|
||||
if (!skeletonData || lastAtlas != Atlas || ForceReload) {
|
||||
if (skeletonData) {
|
||||
delete skeletonData;
|
||||
skeletonData = nullptr;
|
||||
@ -126,6 +126,7 @@ SkeletonData* USpineSkeletonDataAsset::GetSkeletonData (Atlas* Atlas, bool Force
|
||||
}
|
||||
if (animationStateData) {
|
||||
delete animationStateData;
|
||||
animationStateData = nullptr;
|
||||
GetAnimationStateData(Atlas);
|
||||
}
|
||||
lastAtlas = Atlas;
|
||||
|
||||
@ -114,5 +114,6 @@ protected:
|
||||
|
||||
spine::Skeleton* skeleton;
|
||||
USpineAtlasAsset* lastAtlas = nullptr;
|
||||
spine::Atlas* lastSpineAtlas = nullptr;
|
||||
USpineSkeletonDataAsset* lastData = nullptr;
|
||||
};
|
||||
|
||||
@ -1,17 +1,26 @@
|
||||
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace UnrealBuildTool.Rules
|
||||
{
|
||||
public class SpinePlugin : ModuleRules
|
||||
{
|
||||
public SpinePlugin(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PublicIncludePaths.AddRange(new string[] { "SpinePlugin/Public", "SpinePlugin/Public/spine-cpp/include" });
|
||||
PrivateIncludePaths.AddRange(new string[] { "SpinePlugin/Private", "SpinePlugin/Public/spine-cpp/include" });
|
||||
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Public"));
|
||||
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Public/spine-cpp/include"));
|
||||
|
||||
PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "Public"));
|
||||
PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "Public/spine-cpp/include"));
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "RHI", "RenderCore", "ShaderCore", "ProceduralMeshComponent", "UMG", "Slate", "SlateCore" });
|
||||
Definitions.Add("SPINE_UE4");
|
||||
// In Unreal 4.20+, comment the above line, uncomment the below line
|
||||
// PublicDefinitions.Add("SPINE_UE4");
|
||||
PublicDefinitions.Add("SPINE_UE4");
|
||||
|
||||
// For UE 4.19 and below comment the line above and uncomment the line
|
||||
// below.
|
||||
// Definitions.Add("SPINE_UE4");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"EngineAssociation": "4.18",
|
||||
"EngineAssociation": "4.20",
|
||||
"Category": "",
|
||||
"Description": "",
|
||||
"Modules": [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user