4#include "Kismet/GameplayStatics.h"
11 PrimaryComponentTick.bCanEverTick =
false;
86 for (
auto const Component : TargetComponent)
96 TArray<UMeshComponent*> TargetComponent, TArray<int> TargetMaterialIndexes)
108 auto Color = [
this]()->FVector
139 for (TWeakObjectPtr<UMeshComponent> Mesh : TargetMeshes)
141 if (
DeactivatedMeshes.Find(Cast<UStaticMeshComponent>(Mesh.Get())) != INDEX_NONE)
148 if (Cast<UStaticMeshComponent>(Mesh.Get()))
150 Mesh.Get()->SetVectorParameterValueOnMaterials(TEXT(
"EmissiveColor"), Color());
152 else if (Cast<USkeletalMeshComponent>(Mesh.Get()))
154 Mesh->SetVectorParameterValueOnMaterials(TEXT(
"EmissiveColor"), Color());
161 Mesh->SetRenderCustomDepth(
false);
163 Mesh->SetRenderCustomDepth(
true);
171 TArray<TWeakObjectPtr<UMeshComponent>> TargetMeshes, TArray<int> MaterialIndexes)
173 for (TWeakObjectPtr<UMeshComponent> Mesh : TargetMeshes)
175 if (
DeactivatedMeshes.Find(Cast<UStaticMeshComponent>(Mesh.Get())) != INDEX_NONE)
182 if (Cast<UStaticMeshComponent>(Mesh.Get()))
184 for (
int Index : MaterialIndexes)
186 UMaterialInstanceDynamic* DynamicMaterial = Cast<UMaterialInstanceDynamic>(Mesh.Get()->GetMaterial(Index));
187 if (!DynamicMaterial)
189 DynamicMaterial = Mesh.Get()->CreateAndSetMaterialInstanceDynamic(Index);
191 DynamicMaterial->SetVectorParameterValue(TEXT(
"EmissiveColor"), Color());
194 else if (Cast<USkeletalMeshComponent>(Mesh.Get()))
196 for (
int Index : MaterialIndexes)
198 UMaterialInstanceDynamic* DynamicMaterial = Cast<UMaterialInstanceDynamic>(Mesh.Get()->GetMaterial(Index));
199 if (!DynamicMaterial)
201 DynamicMaterial = Mesh.Get()->CreateAndSetMaterialInstanceDynamic(Index);
203 DynamicMaterial->SetVectorParameterValue(TEXT(
"EmissiveColor"), Color());
213 TArray<UStaticMeshComponent*> StaticMeshes;
214 GetOwner()->GetComponents<UStaticMeshComponent>(StaticMeshes);
215 TArray<USkeletalMeshComponent*> SkeletalMeshes;
216 GetOwner()->GetComponents<USkeletalMeshComponent>(SkeletalMeshes);
TMap< EHighlightColor, FLinearColor > ColorMap
void ManuallyActivatePulseHighlightOnSpecificMaterials(bool Activate, TArray< UMeshComponent * > TargetComponent, TArray< int > TargetMaterialIndexes)
Manually activates or deactivates the pulse highlight effect on specific part of the object and speci...
TArray< TWeakObjectPtr< UMeshComponent > > OwnerMeshComponents
TArray< int > AffectedMaterialIndexes
FOnHighlightChanged OnHighlightChanged
UPROPERTY(BlueprintAssignable)
TArray< UStaticMeshComponent * > DeactivatedMeshes
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Highlight")
bool AlwaysEmissiveHighlight
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Highlight")
void UpdatedOwnerMeshComponents()
void PerformPulseHighlight()
UFUNCTION()
bool IsShowHighlight
UPROPERTY()
FTimerHandle PulseHighlightTimerHandle
UPROPERTY(BlueprintReadWrite)
virtual void BeginPlay() override
void ChangeHighlightMaterialColor(const TFunctionRef< FVector()> Color, TArray< TWeakObjectPtr< UMeshComponent > > TargetMeshes)
void ManuallyActivatePulseHighlight(bool Activate, TArray< UMeshComponent * > TargetComponent)
Manually activates or deactivates the pulse highlight effect on specific part of the object.
void ChangeHighlightSpecificMaterialColor(const TFunctionRef< FVector()> Color, TArray< TWeakObjectPtr< UMeshComponent > > TargetMeshes, TArray< int > MaterialIndexes)
EHighlightColor CurrentHighlight
UPROPERTY()
void UpdateHighlightValue(EHighlightColor HighlightColor)
Updates the highlight color of the object.
void ActivatePulseHighlight(bool Activate)
Activates or deactivates the pulse highlight effect.
FOnHighlightValueChanged OnHighlightValueChanged
UPROPERTY(BlueprintAssignable)