You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Moved SmartObjects out of restricted folder Moved StateTree out of restricted folder Moved ZoneGraph out of restricted folder Moved ZoneGraphAnnotations out of restricted folder #jira UE-115297 #ROBOMERGE-OWNER: mieszko.zielinski #ROBOMERGE-AUTHOR: mieszko.zielinski #ROBOMERGE-SOURCE: CL 17648223 via CL 17648246 via CL 17648261 via CL 17648385 via CL 17648390 via CL 17648742 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Test -> Main) (v875-17642767) [CL 17648750 by mieszko zielinski in ue5-main branch]
88 lines
2.6 KiB
C++
88 lines
2.6 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "GenericSmartObject.h"
|
|
#include "UObject/ConstructorHelpers.h"
|
|
#include "Components/ArrowComponent.h"
|
|
#include "Components/SceneComponent.h"
|
|
#include "Engine/Texture2D.h"
|
|
#include "Components/BillboardComponent.h"
|
|
#include "SmartObjectRenderingComponent.h"
|
|
#include "SmartObjectComponent.h"
|
|
|
|
#if WITH_EDITOR
|
|
#include "ObjectEditorUtils.h"
|
|
#endif // WITH_EDITOR
|
|
|
|
|
|
AGenericSmartObject::AGenericSmartObject(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
USceneComponent* SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComp"));
|
|
RootComponent = SceneComponent;
|
|
RootComponent->Mobility = EComponentMobility::Static;
|
|
|
|
SOComponent = CreateDefaultSubobject<USmartObjectComponent>(TEXT("SmartObjectComp"));
|
|
SOComponent->SetupAttachment(RootComponent);
|
|
|
|
#if WITH_EDITORONLY_DATA
|
|
UBillboardComponent* SpriteComponent = CreateEditorOnlyDefaultSubobject<UBillboardComponent>(TEXT("Sprite"));
|
|
RenderingComponent = CreateEditorOnlyDefaultSubobject<USmartObjectRenderingComponent>(TEXT("RenderComp"));
|
|
|
|
if (!IsRunningCommandlet())
|
|
{
|
|
// Structure to hold one-time initialization
|
|
struct FConstructorStatics
|
|
{
|
|
ConstructorHelpers::FObjectFinderOptional<UTexture2D> NoteTextureObject;
|
|
FName NotesID;
|
|
FText GenericSOName;
|
|
FConstructorStatics()
|
|
: NoteTextureObject(TEXT("/SmartObjects/S_BrainInBox"))
|
|
, NotesID(TEXT("SmartObject"))
|
|
, GenericSOName(NSLOCTEXT("SpriteCategory", "GenericSO", "GenericSO"))
|
|
{
|
|
}
|
|
};
|
|
static FConstructorStatics ConstructorStatics;
|
|
if (SpriteComponent)
|
|
{
|
|
SpriteComponent->Sprite = ConstructorStatics.NoteTextureObject.Get();
|
|
SpriteComponent->SetRelativeScale3D_Direct(FVector(0.5f, 0.5f, 0.5f));
|
|
SpriteComponent->SpriteInfo.Category = ConstructorStatics.NotesID;
|
|
SpriteComponent->SpriteInfo.DisplayName = ConstructorStatics.GenericSOName;
|
|
SpriteComponent->SetupAttachment(RootComponent);
|
|
SpriteComponent->Mobility = EComponentMobility::Static;
|
|
}
|
|
|
|
if (RenderingComponent)
|
|
{
|
|
RenderingComponent->SetupAttachment(RootComponent);
|
|
}
|
|
}
|
|
|
|
#endif // WITH_EDITORONLY_DATA
|
|
|
|
SetHidden(true);
|
|
SetCanBeDamaged(false);
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
void AGenericSmartObject::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
|
{
|
|
static const FName SmartObjectName = FName(TEXT("SmartObject"));
|
|
|
|
Super::PostEditChangeProperty(PropertyChangedEvent);
|
|
|
|
if (PropertyChangedEvent.Property)
|
|
{
|
|
if (FObjectEditorUtils::GetCategoryFName(PropertyChangedEvent.Property) == SmartObjectName)
|
|
{
|
|
if (RenderingComponent)
|
|
{
|
|
MarkComponentsRenderStateDirty();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif // WITH_EDITOR
|