You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
[SmartObject] added component instance data for SmartObjectComponent so component can properly register itself while re-running the construction scripts.
This is required since the newly created components in the process will try to register before the Definition asset gets set. #rb maxime.mercier #rnx #preflight 61faf0935e35b9215bfedaab #ROBOMERGE-AUTHOR: yoan.stamant #ROBOMERGE-SOURCE: CL 18841643 via CL 18842123 via CL 18842168 via CL 18845170 via CL 18845776 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18845836 by yoan stamant in ue5-main branch]
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
#include "Engine/World.h"
|
||||
#endif
|
||||
|
||||
|
||||
USmartObjectComponent::USmartObjectComponent(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
@@ -20,6 +19,11 @@ void USmartObjectComponent::OnRegister()
|
||||
{
|
||||
Super::OnRegister();
|
||||
|
||||
RegisterToSubsystem();
|
||||
}
|
||||
|
||||
void USmartObjectComponent::RegisterToSubsystem()
|
||||
{
|
||||
const UWorld* World = GetWorld();
|
||||
if (World == nullptr)
|
||||
{
|
||||
@@ -102,3 +106,35 @@ FBox USmartObjectComponent::GetSmartObjectBounds() const
|
||||
|
||||
return BoundingBox;
|
||||
}
|
||||
|
||||
TStructOnScope<FActorComponentInstanceData> USmartObjectComponent::GetComponentInstanceData() const
|
||||
{
|
||||
return MakeStructOnScope<FActorComponentInstanceData, FSmartObjectComponentInstanceData>(this, DefinitionAsset);
|
||||
}
|
||||
|
||||
bool FSmartObjectComponentInstanceData::ContainsData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void FSmartObjectComponentInstanceData::ApplyToComponent(UActorComponent* Component, const ECacheApplyPhase CacheApplyPhase)
|
||||
{
|
||||
// Apply data first since we might need to register to the subsystem
|
||||
// before the component gets re-registered by the base class.
|
||||
if (CacheApplyPhase == ECacheApplyPhase::PostUserConstructionScript)
|
||||
{
|
||||
USmartObjectComponent* SmartObjectComponent = CastChecked<USmartObjectComponent>(Component);
|
||||
if (SmartObjectComponent->DefinitionAsset != DefinitionAsset)
|
||||
{
|
||||
SmartObjectComponent->DefinitionAsset = DefinitionAsset;
|
||||
// Registering to the subsystem should only be attempted on registered component
|
||||
// otherwise the OnRegister callback will take care of it.
|
||||
if (SmartObjectComponent->IsRegistered())
|
||||
{
|
||||
SmartObjectComponent->RegisterToSubsystem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Super::ApplyToComponent(Component, CacheApplyPhase);
|
||||
}
|
||||
Reference in New Issue
Block a user