8 PrimaryComponentTick.bCanEverTick =
true;
10 static ConstructorHelpers::FObjectFinder<UCurveFloat> FadeOpacityCurveAsset(TEXT(
"CurveFloat'/PixoCore/Blueprints/FadeOpacityCurve.FadeOpacityCurve'"));
30 UE_LOG(LogTemp,
Error, TEXT(
"UFadingComponent::FadeStaticMeshes: FinalOpacity equals CurrentOpacity"));
34 if (StaticMeshes.Num() == 0)
36 UE_LOG(LogTemp,
Error, TEXT(
"UFadingComponent::FadeStaticMeshes: TargetMeshes array is empty"));
44 if (!Mesh->IsValidLowLevelFast())
46 UE_LOG(LogTemp,
Error, TEXT(
"UFadingComponent::FadeStaticMeshes: Mesh isn't valid"));
49 AActor* Owner = Mesh->GetOwner();
52 TArray<FTransparentMaterialData> MaterialDataTemp = IPixoVRStoryObject::Execute_GetActorTransparentMaterialData(Owner);
54 if (MaterialDataTemp.Num() != 0)
58 return MeshDataIt.
MeshRef == Mesh;
64 UE_LOG(LogTemp,
Error, TEXT(
"UFadingComponent::FadeStaticMeshes: There is no MaterialData for %s mesh"), *Mesh->GetName());
68 UE_LOG(LogTemp,
Error, TEXT(
"UFadingComponent::FadeStaticMeshes: Actor has no transparent data!"));
69 GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red,
"UFadingComponent::FadeStaticMeshes: Actor has no transparent data!");
74 UE_LOG(LogTemp,
Error, TEXT(
"UFadingComponent::FadeStaticMeshes: Actor doesn't implement interface!"));
75 GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red,
"UFadingComponent::FadeStaticMeshes: Actor doesn't implement interface!");
90 TArray<UStaticMeshComponent*> ActorStaticMeshes;
112 FOnTimelineFloat TimelineProgress;
113 TimelineProgress.BindUFunction(
this,
FName(
"FadeOpacityTimelineProcess"));
122 GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red,
"UFadingComponent::BeginPlay Setup ChangingFadeOpacityCurve");
130 for (
int MaterialIndex = 0; MaterialIndex < TransparentMaterialData.MI_OpaqueMaterials.Num(); MaterialIndex++)
132 TransparentMaterialData.MeshRef->SetMaterial(MaterialIndex, TransparentMaterialData.MI_OpaqueMaterials[MaterialIndex]);
141 TransparentMaterialData.MeshRef->SetHiddenInGame(Hidden);
147 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
156 for (
int MaterialIndex = 0; MaterialIndex < TransparentMaterialData.MI_TransparentMaterials.Num(); MaterialIndex++)
158 TransparentMaterialData.MeshRef->SetMaterial(MaterialIndex, TransparentMaterialData.MI_TransparentMaterials[MaterialIndex]);
188 TransparentMaterialData.MeshRef->SetScalarParameterValueOnMaterials(
"Opacity", Value);
void FadeStaticMeshes(TArray< UStaticMeshComponent * > StaticMeshes, float TimeForFade=1.0f, float DesiredOpacity=0.0f)
Function that allows you to fade meshes to smoothly make them invisible, ghost or visible (Owner shou...
void FadeCompleted()
UFUNCTION()
void FadeOpacityTimelineProcess(float Value)
UFUNCTION()
FOnFadeCompleted OnFadeCompleted
UPROPERTY(BlueprintAssignable)
void SetOpaqueMaterial()
Sets opaque material if mesh is visible to reduce the consumption of resources for rendering.
void SetOpacity(float Value)
Set opacity for meshes in MaterialData.
void FadeStaticMeshesFromTo(TArray< UStaticMeshComponent * > StaticMeshes, float TimeForFade=1.0f, float FromOpacity=0.0f, float ToOpacity=0.0f)
Function that allows you to fade meshes to smoothly make them invisible, ghost or visible (Owner shou...
virtual void BeginPlay() override
void SetMeshesHidden(bool Hidden)
Sets meshes hidden if mesh is invisible to reduce the consumption of resources for rendering.
void FadeActor(AActor *Actor, float TimeForFade=1.0f, float DesiredOpacity=0.0f)
Function that allows you to fade actor to smoothly make them invisible, ghost or visible (Actor shoul...
UCurveFloat * ChangingFadeOpacityCurve
UPROPERTY()
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
TArray< FTransparentMaterialData > MaterialData
UPROPERTY()
Struct used in Fadable component.
UStaticMeshComponent * MeshRef
UPROPERTY(BlueprintReadWrite)