本文整理汇总了C++中UMaterial::IsUIMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ UMaterial::IsUIMaterial方法的具体用法?C++ UMaterial::IsUIMaterial怎么用?C++ UMaterial::IsUIMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMaterial
的用法示例。
在下文中一共展示了UMaterial::IsUIMaterial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMaterialInterface
void FMaterialThumbnailScene::SetMaterialInterface(UMaterialInterface* InMaterial)
{
check(PreviewActor);
check(PreviewActor->GetStaticMeshComponent());
bIsUIMaterial = false;
if ( InMaterial )
{
// Transform the preview mesh as necessary
FTransform Transform = FTransform::Identity;
const USceneThumbnailInfoWithPrimitive* ThumbnailInfo = Cast<USceneThumbnailInfoWithPrimitive>(InMaterial->ThumbnailInfo);
if ( !ThumbnailInfo )
{
ThumbnailInfo = USceneThumbnailInfoWithPrimitive::StaticClass()->GetDefaultObject<USceneThumbnailInfoWithPrimitive>();
}
UMaterial* BaseMaterial = InMaterial->GetBaseMaterial();
// UI material thumbnails always get a 2D plane centered at the camera which is a better representation of the
// what the material will look like on UI
bIsUIMaterial = BaseMaterial && BaseMaterial->IsUIMaterial();
EThumbnailPrimType PrimitiveType = bIsUIMaterial ? TPT_Plane : ThumbnailInfo->PrimitiveType.GetValue();
switch( PrimitiveType )
{
case TPT_None:
{
bool bFoundCustomMesh = false;
if ( ThumbnailInfo->PreviewMesh.IsValid() )
{
UStaticMesh* MeshToUse = Cast<UStaticMesh>(ThumbnailInfo->PreviewMesh.ResolveObject());
if ( MeshToUse )
{
PreviewActor->GetStaticMeshComponent()->SetStaticMesh(MeshToUse);
bFoundCustomMesh = true;
}
}
if ( !bFoundCustomMesh )
{
// Just use a plane if the mesh was not found
Transform.SetRotation(FQuat(FRotator(0, -90, 0)));
PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorPlane);
}
}
break;
case TPT_Cube:
PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorCube);
break;
case TPT_Sphere:
// The sphere is a little big, scale it down to 256x256x256
Transform.SetScale3D( FVector(0.8f) );
PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorSphere);
break;
case TPT_Cylinder:
PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorCylinder);
break;
case TPT_Plane:
// The plane needs to be rotated 90 degrees to face the camera
Transform.SetRotation(FQuat(FRotator(0, -90, 0)));
PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorPlane);
break;
default:
check(0);
}
PreviewActor->GetStaticMeshComponent()->SetRelativeTransform(Transform);
PreviewActor->GetStaticMeshComponent()->UpdateBounds();
// Center the mesh at the world origin then offset to put it on top of the plane
const float BoundsZOffset = GetBoundsZOffset(PreviewActor->GetStaticMeshComponent()->Bounds);
Transform.SetLocation(-PreviewActor->GetStaticMeshComponent()->Bounds.Origin + FVector(0, 0, BoundsZOffset));
PreviewActor->GetStaticMeshComponent()->SetRelativeTransform(Transform);
}
PreviewActor->GetStaticMeshComponent()->SetMaterial(0, InMaterial);
PreviewActor->GetStaticMeshComponent()->RecreateRenderState_Concurrent();
}