本文整理汇总了C++中UPaperSprite::ExtractSourceRegionFromTexturePoint方法的典型用法代码示例。如果您正苦于以下问题:C++ UPaperSprite::ExtractSourceRegionFromTexturePoint方法的具体用法?C++ UPaperSprite::ExtractSourceRegionFromTexturePoint怎么用?C++ UPaperSprite::ExtractSourceRegionFromTexturePoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UPaperSprite
的用法示例。
在下文中一共展示了UPaperSprite::ExtractSourceRegionFromTexturePoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessClick
void FSpriteEditorViewportClient::ProcessClick(FSceneView& View, HHitProxy* HitProxy, FKey Key, EInputEvent Event, uint32 HitX, uint32 HitY)
{
const FViewportClick Click(&View, this, Key, Event, HitX, HitY);
const bool bIsCtrlKeyDown = Viewport->KeyState(EKeys::LeftControl) || Viewport->KeyState(EKeys::RightControl);
const bool bIsShiftKeyDown = Viewport->KeyState(EKeys::LeftShift) || Viewport->KeyState(EKeys::RightShift);
const bool bIsAltKeyDown = Viewport->KeyState(EKeys::LeftAlt) || Viewport->KeyState(EKeys::RightAlt);
bool bHandled = false;
HSpriteSelectableObjectHitProxy* SelectedItemProxy = HitProxyCast<HSpriteSelectableObjectHitProxy>(HitProxy);
if (IsInSourceRegionEditMode())
{
if ((Event == EInputEvent::IE_DoubleClick) && (Key == EKeys::LeftMouseButton))
{
FVector4 WorldPoint = View.PixelToWorld(HitX, HitY, 0);
UPaperSprite* Sprite = GetSpriteBeingEdited();
FVector2D TexturePoint = SourceTextureViewComponent->GetSprite()->ConvertWorldSpaceToTextureSpace(WorldPoint);
if (bIsCtrlKeyDown)
{
const FVector2D StartingUV = Sprite->GetSourceUV();
const FVector2D StartingSize = Sprite->GetSourceSize();
if (UPaperSprite* NewSprite = CreateNewSprite(FIntPoint((int32)StartingUV.X, (int32)StartingUV.Y), FIntPoint((int32)StartingSize.X, (int32)StartingSize.Y)))
{
NewSprite->ExtractSourceRegionFromTexturePoint(TexturePoint);
bHandled = true;
}
}
else
{
Sprite->ExtractSourceRegionFromTexturePoint(TexturePoint);
bHandled = true;
}
}
else if ((Event == EInputEvent::IE_Released) && (Key == EKeys::LeftMouseButton))
{
FVector4 WorldPoint = View.PixelToWorld(HitX, HitY, 0);
FVector2D TexturePoint = SourceTextureViewComponent->GetSprite()->ConvertWorldSpaceToTextureSpace(WorldPoint);
for (int32 RelatedSpriteIndex = 0; RelatedSpriteIndex < RelatedSprites.Num(); ++RelatedSpriteIndex)
{
FRelatedSprite& RelatedSprite = RelatedSprites[RelatedSpriteIndex];
if ((TexturePoint.X >= RelatedSprite.SourceUV.X) && (TexturePoint.Y >= RelatedSprite.SourceUV.Y) &&
(TexturePoint.X < (RelatedSprite.SourceUV.X + RelatedSprite.SourceDimension.X)) &&
(TexturePoint.Y < (RelatedSprite.SourceUV.Y + RelatedSprite.SourceDimension.Y)))
{
bHandled = true;
// Select this sprite
if (UPaperSprite* LoadedSprite = Cast<UPaperSprite>(RelatedSprite.AssetData.GetAsset()))
{
if (SpriteEditorPtr.IsValid())
{
SpriteEditorPtr.Pin()->SetSpriteBeingEdited(LoadedSprite);
break;
}
}
}
}
}
}
if (!bHandled)
{
FPaperEditorViewportClient::ProcessClick(View, HitProxy, Key, Event, HitX, HitY);
}
}