UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UMeshComponent Class Reference

#include <MeshComponent.h>

+ Inheritance diagram for UMeshComponent:

Classes

struct  FMaterialParameterCache
 

Public Member Functions

virtual ENGINE_API TArray< class UMaterialInterface * > GetMaterials () const
 
virtual bool UseNaniteOverrideMaterials () const
 
virtual ENGINE_API int32 GetNumOverrideMaterials () const
 
ENGINE_API class UMaterialInterfaceGetOverlayMaterial () const
 
ENGINE_API void SetOverlayMaterial (class UMaterialInterface *NewOverlayMaterial)
 
ENGINE_API float GetOverlayMaterialMaxDrawDistance () const
 
ENGINE_API void SetOverlayMaterialMaxDrawDistance (float InMaxDrawDistance)
 
ENGINE_API void GetMaterialSlotsOverlayMaterial (TArray< TObjectPtr< class UMaterialInterface > > &OutMaterialSlotOverlayMaterials) const
 
ENGINE_API void EmptyOverrideMaterials ()
 
ENGINE_API bool HasOverrideMaterials ()
 
virtual ENGINE_API int32 GetNumMaterials () const override
 
virtual ENGINE_API UMaterialInterfaceGetMaterial (int32 ElementIndex) const override
 
virtual ENGINE_API UMaterialInterfaceGetMaterialByName (FName MaterialSlotName) const override
 
virtual ENGINE_API void SetMaterial (int32 ElementIndex, UMaterialInterface *Material) override
 
virtual ENGINE_API void SetMaterialByName (FName MaterialSlotName, class UMaterialInterface *Material) override
 
virtual ENGINE_API void GetUsedMaterials (TArray< UMaterialInterface * > &OutMaterials, bool bGetDebugMaterials=false) const override
 
virtual ENGINE_API FMaterialRelevance GetMaterialRelevance (ERHIFeatureLevel::Type InFeatureLevel) const
 
virtual ENGINE_API FMaterialRelevance GetMaterialRelevance (EShaderPlatform InShaderPlatform) const
 
virtual ENGINE_API void SetTextureForceResidentFlag (bool bForceMiplevelsToBeResident)
 
virtual ENGINE_API void PrestreamTextures (float Seconds, bool bPrioritizeCharacterTextures, int32 CinematicTextureGroups=0)
 
virtual bool PrestreamMeshLODs (float Seconds)
 
virtual ENGINE_API void RegisterLODStreamingCallback (FLODStreamingCallback &&Callback, int32 LODIdx, float TimeoutSecs, bool bOnStreamIn)
 
virtual ENGINE_API void RegisterLODStreamingCallback (FLODStreamingCallback &&CallbackStreamingStart, FLODStreamingCallback &&CallbackStreamingDone, float TimeoutStartSecs, float TimeoutDoneSecs)
 
virtual bool GetMaterialStreamingData (int32 MaterialIndex, FPrimitiveMaterialInfo &MaterialData) const
 
ENGINE_API void GetStreamingTextureInfoInner (FStreamingTextureLevelContext &LevelContext, const TArray< FStreamingTextureBuildInfo > *PreBuiltData, float ComponentScaling, TArray< FStreamingRenderAssetPrimitiveInfo > &OutStreamingTextures) const
 
ENGINE_API FColor GetWireframeColorForSceneProxy () const
 
virtual ENGINE_API void LogMaterialsAndTextures (FOutputDevice &Ar, int32 Indent) const
 
virtual UTextureGetMeshPaintTexture () const
 
virtual void SetMeshPaintTexture (UTexture *Texture)
 
virtual void SetMeshPaintTextureOverride (UTexture *OverrideTexture)
 
virtual int32 GetMeshPaintTextureCoordinateIndex () const
 
ENGINE_API void SetScalarParameterValueOnMaterials (const FName ParameterName, const float ParameterValue)
 
ENGINE_API void SetVectorParameterValueOnMaterials (const FName ParameterName, const FVector ParameterValue)
 
ENGINE_API void SetColorParameterValueOnMaterials (const FName ParameterName, const FLinearColor ParameterValue)
 
float GetScalarParameterDefaultValue (const FName ParameterName)
 
ENGINE_API const TArray< TObjectPtr< UMaterialInterface > > & GetComponentMaterialSlotsOverlayMaterial () const
 
virtual void GetDefaultMaterialSlotsOverlayMaterial (TArray< TObjectPtr< UMaterialInterface > > &OutMaterialSlotOverlayMaterials) const
 

Public Attributes

TArray< TObjectPtr< class UMaterialInterface > > OverrideMaterials
 
TObjectPtr< class UMaterialInterfaceOverlayMaterial
 
float OverlayMaterialMaxDrawDistance
 
TArray< TObjectPtr< class UMaterialInterface > > MaterialSlotsOverlayMaterial
 
uint8 bEnableMaterialParameterCaching: 1
 

Protected Member Functions

virtual ENGINE_API void BeginDestroy () override
 
virtual UMaterialInterfaceGetDefaultOverlayMaterial () const
 
virtual float GetDefaultOverlayMaterialMaxDrawDistance () const
 
ENGINE_API void CacheMaterialParameterNameIndices ()
 
ENGINE_API void MarkCachedMaterialParameterNameIndicesDirty ()
 

Protected Attributes

uint8 bCachedMaterialParameterIndicesAreDirty: 1
 
TSortedMap< FName, FMaterialParameterCache, FDefaultAllocator, FNameFastLessMaterialParameterCache
 

Detailed Description

MeshComponent is an abstract base for any component that is an instance of a renderable collection of triangles.

See also
UStaticMeshComponent
USkeletalMeshComponent

Member Function Documentation

◆ BeginDestroy()

void UMeshComponent::BeginDestroy ( )
overrideprotectedvirtual

Reimplemented in USkinnedMeshComponent.

◆ CacheMaterialParameterNameIndices()

void UMeshComponent::CacheMaterialParameterNameIndices ( )
protected

Retrieves all the (scalar/vector-)parameters from within the used materials on the SkeletalMesh, and stores material index vs parameter names

◆ EmptyOverrideMaterials()

void UMeshComponent::EmptyOverrideMaterials ( )

This empties all override materials and used by editor when replacing preview mesh

◆ GetComponentMaterialSlotsOverlayMaterial()

const TArray< TObjectPtr< UMaterialInterface > > & UMeshComponent::GetComponentMaterialSlotsOverlayMaterial ( ) const

Retrieve the material slots overly materials assigned to this component

◆ GetDefaultMaterialSlotsOverlayMaterial()

virtual void UMeshComponent::GetDefaultMaterialSlotsOverlayMaterial ( TArray< TObjectPtr< UMaterialInterface > > &  OutMaterialSlotOverlayMaterials) const
inlinevirtual

Get all default material slots overlay materials from the mesh.

Reimplemented in USkinnedMeshComponent.

◆ GetDefaultOverlayMaterial()

virtual UMaterialInterface * UMeshComponent::GetDefaultOverlayMaterial ( ) const
inlineprotectedvirtual

Get the default overlay material used by a mesh

Reimplemented in USkinnedMeshComponent.

◆ GetDefaultOverlayMaterialMaxDrawDistance()

virtual float UMeshComponent::GetDefaultOverlayMaterialMaxDrawDistance ( ) const
inlineprotectedvirtual

Get the default overlay material max draw distance

Reimplemented in USkinnedMeshComponent.

◆ GetMaterial()

UMaterialInterface * UMeshComponent::GetMaterial ( int32  ElementIndex) const
overridevirtual

◆ GetMaterialByName()

UMaterialInterface * UMeshComponent::GetMaterialByName ( FName  MaterialSlotName) const
overridevirtual

Reimplemented in UBaseDynamicMeshComponent.

◆ GetMaterialRelevance() [1/2]

FMaterialRelevance UMeshComponent::GetMaterialRelevance ( ERHIFeatureLevel::Type  InFeatureLevel) const
virtual

Accesses the scene relevance information for the materials applied to the mesh. Valid from game thread only.

Reimplemented in UGeometryCollectionComponent, and UBaseDynamicMeshComponent.

◆ GetMaterialRelevance() [2/2]

FMaterialRelevance UMeshComponent::GetMaterialRelevance ( EShaderPlatform  InShaderPlatform) const
virtual

◆ GetMaterials()

TArray< class UMaterialInterface * > UMeshComponent::GetMaterials ( ) const
virtual

◆ GetMaterialSlotsOverlayMaterial()

void UMeshComponent::GetMaterialSlotsOverlayMaterial ( TArray< TObjectPtr< class UMaterialInterface > > &  OutMaterialSlotOverlayMaterials) const

Fill the array with every material slot overlay material use by this instance.

If this component material slot overlay material will be used if not null. If there is no valid component material slot overlay material, the mesh material slot overlay material will be used if not null. If there is no valid asset material slot overlay material, a null entry will be set for the material slot overlay material.

◆ GetMaterialStreamingData()

virtual bool UMeshComponent::GetMaterialStreamingData ( int32  MaterialIndex,
FPrimitiveMaterialInfo MaterialData 
) const
inlinevirtual

Get the material info for texture streaming. Return whether the data is valid or not.

Reimplemented in USkinnedMeshComponent.

◆ GetMeshPaintTexture()

virtual UTexture * UMeshComponent::GetMeshPaintTexture ( ) const
inlinevirtual

Get the mesh paint texture set on this component. This does not take into account any transient override.

◆ GetMeshPaintTextureCoordinateIndex()

virtual int32 UMeshComponent::GetMeshPaintTextureCoordinateIndex ( ) const
inlinevirtual

Get the default coordinate index for painting to the mesh paint texture on this component.

◆ GetNumMaterials()

int32 UMeshComponent::GetNumMaterials ( ) const
overridevirtual

◆ GetNumOverrideMaterials()

int32 UMeshComponent::GetNumOverrideMaterials ( ) const
virtual

Returns override materials count

◆ GetOverlayMaterial()

UMaterialInterface * UMeshComponent::GetOverlayMaterial ( ) const

Get the overlay material used by this instance

◆ GetOverlayMaterialMaxDrawDistance()

float UMeshComponent::GetOverlayMaterialMaxDrawDistance ( ) const

Get the overlay material used by this instance

◆ GetScalarParameterDefaultValue()

float UMeshComponent::GetScalarParameterDefaultValue ( const FName  ParameterName)
inline

Returns default value for the parameter input.

NOTE: This is not reliable when cooking, as initializing the default value requires a render resource that only exists if the owning world is rendering.

◆ GetStreamingTextureInfoInner()

void UMeshComponent::GetStreamingTextureInfoInner ( FStreamingTextureLevelContext LevelContext,
const TArray< FStreamingTextureBuildInfo > *  PreBuiltData,
float  ComponentScaling,
TArray< FStreamingRenderAssetPrimitiveInfo > &  OutStreamingTextures 
) const

Generate streaming data for all materials.

◆ GetUsedMaterials()

void UMeshComponent::GetUsedMaterials ( TArray< UMaterialInterface * > &  OutMaterials,
bool  bGetDebugMaterials = false 
) const
overridevirtual

◆ GetWireframeColorForSceneProxy()

FColor UMeshComponent::GetWireframeColorForSceneProxy ( ) const

Returns the wireframe color to use for this component.

◆ HasOverrideMaterials()

bool UMeshComponent::HasOverrideMaterials ( )

Returns true if there are any override materials set for this component

◆ LogMaterialsAndTextures()

void UMeshComponent::LogMaterialsAndTextures ( FOutputDevice Ar,
int32  Indent 
) const
virtual

Output to the log which materials and textures are used by this component.

Parameters
IndentNumber of tabs to put before the log.

◆ MarkCachedMaterialParameterNameIndicesDirty()

void UMeshComponent::MarkCachedMaterialParameterNameIndicesDirty ( )
protected

Mark cache parameters map as dirty, cache will be rebuild once SetScalar/SetVector functions are called

◆ PrestreamMeshLODs()

virtual bool UMeshComponent::PrestreamMeshLODs ( float  Seconds)
inlinevirtual

Tell the streaming system to start streaming in all LODs for the mesh. Note: this function may set bIgnoreStreamingMipBias on this component enable the FastForceResident system.

Returns
bool True if streaming was successfully requested
Parameters
SecondsNumber of seconds to force all LODs to be resident

Reimplemented in USkinnedMeshComponent.

◆ PrestreamTextures()

void UMeshComponent::PrestreamTextures ( float  Seconds,
bool  bPrioritizeCharacterTextures,
int32  CinematicTextureGroups = 0 
)
virtual

Tell the streaming system to start loading all textures with all mip-levels.

Parameters
SecondsNumber of seconds to force all mip-levels to be resident
bPrioritizeCharacterTexturesWhether character textures should be prioritized for a while by the streaming system
CinematicTextureGroupsBitfield indicating which texture groups that use extra high-resolution mips

◆ RegisterLODStreamingCallback() [1/2]

void UMeshComponent::RegisterLODStreamingCallback ( FLODStreamingCallback &&  Callback,
int32  LODIdx,
float  TimeoutSecs,
bool  bOnStreamIn 
)
virtual

Register a one-time callback that will be called when criteria met

Parameters
Callback
LODIdxThe LOD index expected. Specify -1 for the MinLOD.
TimeoutSecsTimeout in seconds
bOnStreamInTo get notified when the expected LOD is streamed in or out

Reimplemented in USkinnedMeshComponent.

◆ RegisterLODStreamingCallback() [2/2]

void UMeshComponent::RegisterLODStreamingCallback ( FLODStreamingCallback &&  CallbackStreamingStart,
FLODStreamingCallback &&  CallbackStreamingDone,
float  TimeoutStartSecs,
float  TimeoutDoneSecs 
)
virtual

Register a one-time callback that will be called when streaming starts or ends.

Parameters
CallbackStreamingStartThe callback to notify when streaming new LODs in begins. The callback will not always be called if the asset is not streamable, or the asset or component is unloaded.
CallbackStreamingDoneThe callback to notify when streaming is done. The callback will not be called if the start timeout expired.
TimeoutStartSecsTimeout for streaming to start, in seconds
TimeoutDoneSecsTimeout for streaming to end, in seconds

Reimplemented in USkinnedMeshComponent.

◆ SetColorParameterValueOnMaterials()

void UMeshComponent::SetColorParameterValueOnMaterials ( const FName  ParameterName,
const FLinearColor  ParameterValue 
)

Set all occurrences of Vector Material Parameters with ParameterName in the set of materials of the SkeletalMesh to ParameterValue

◆ SetMaterial()

void UMeshComponent::SetMaterial ( int32  ElementIndex,
UMaterialInterface Material 
)
overridevirtual

Reimplemented in UBaseDynamicMeshComponent.

◆ SetMaterialByName()

void UMeshComponent::SetMaterialByName ( FName  MaterialSlotName,
class UMaterialInterface Material 
)
overridevirtual

◆ SetMeshPaintTexture()

virtual void UMeshComponent::SetMeshPaintTexture ( UTexture Texture)
inlinevirtual

Set the mesh paint texture on this component.

◆ SetMeshPaintTextureOverride()

virtual void UMeshComponent::SetMeshPaintTextureOverride ( UTexture OverrideTexture)
inlinevirtual

Set a transient override mesh paint texture on this component.

◆ SetOverlayMaterial()

void UMeshComponent::SetOverlayMaterial ( class UMaterialInterface NewOverlayMaterial)

Change the overlay material used by this instance

◆ SetOverlayMaterialMaxDrawDistance()

void UMeshComponent::SetOverlayMaterialMaxDrawDistance ( float  InMaxDrawDistance)

Change the overlay material max draw distance used by this instance

◆ SetScalarParameterValueOnMaterials()

void UMeshComponent::SetScalarParameterValueOnMaterials ( const FName  ParameterName,
const float  ParameterValue 
)

Set all occurrences of Scalar Material Parameters with ParameterName in the set of materials of the SkeletalMesh to ParameterValue

◆ SetTextureForceResidentFlag()

void UMeshComponent::SetTextureForceResidentFlag ( bool  bForceMiplevelsToBeResident)
virtual

Tell the streaming system whether or not all mip levels of all textures used by this component should be loaded and remain loaded.

Parameters
bForceMiplevelsToBeResidentWhether textures should be forced to be resident or not.

◆ SetVectorParameterValueOnMaterials()

void UMeshComponent::SetVectorParameterValueOnMaterials ( const FName  ParameterName,
const FVector  ParameterValue 
)

Set all occurrences of Vector Material Parameters with ParameterName in the set of materials of the SkeletalMesh to ParameterValue

◆ UseNaniteOverrideMaterials()

virtual bool UMeshComponent::UseNaniteOverrideMaterials ( ) const
inlinevirtual

Determines if we use the nanite overrides from any materials

Member Data Documentation

◆ bCachedMaterialParameterIndicesAreDirty

uint8 UMeshComponent::bCachedMaterialParameterIndicesAreDirty
protected

Flag whether or not the cached material parameter indices map is dirty (defaults to true, and is set from SetMaterial/Set(Skeletal)Mesh

◆ bEnableMaterialParameterCaching

uint8 UMeshComponent::bEnableMaterialParameterCaching

Whether or not to cache material parameter to speed up setting scalar or vector value on materials

◆ MaterialParameterCache

TSortedMap<FName, FMaterialParameterCache, FDefaultAllocator, FNameFastLess> UMeshComponent::MaterialParameterCache
protected

◆ MaterialSlotsOverlayMaterial

TArray<TObjectPtr<class UMaterialInterface> > UMeshComponent::MaterialSlotsOverlayMaterial

Translucent material to blend on top of this mesh. Mesh will be rendered twice - once with a base material and once with overlay material. The difference with the global OverlayMaterial is those are per material slot, if the entry is null or doesn't exist the global OverlayMaterial will be use for sections using the material slot.

◆ OverlayMaterial

TObjectPtr<class UMaterialInterface> UMeshComponent::OverlayMaterial

Translucent material to blend on top of this mesh. Mesh will be rendered twice - once with a base material and once with overlay material

◆ OverlayMaterialMaxDrawDistance

float UMeshComponent::OverlayMaterialMaxDrawDistance

The max draw distance for overlay material. A distance of 0 indicates that overlay will be culled using primitive max distance.

◆ OverrideMaterials

TArray<TObjectPtr<class UMaterialInterface> > UMeshComponent::OverrideMaterials

Per-Component material overrides. These must NOT be set directly or a race condition can occur between GC and the rendering thread.


The documentation for this class was generated from the following files: