TimGS
(TimGS)
September 23, 2014, 7:08am
1
Image is not stretching. Box and border do. When you set margin you divide your texture into 9 sections. Box leaves corners alone, stretches upper and lower edges sections horizontally, right and left edges sections vertically and middle - uniformly.
When you set margin to 0 you basically put your whole texture to middle section and it stretches uniformly filling the space you set for it.
envenger
(envenger)
September 23, 2014, 5:46am
2
I need to resize an image and fit it in a small place. I am using SBox to achive it. But instead of resizing, the image size remains the same and only a small part of it is visible.
This is what I am currently getting.
SNew(SBox)
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.WidthOverride(16)
.HeightOverride(16)
[
SNew(SImage)
.Image(&GalaxyHUD->NuclearResourceImg)
]
TimGS
(TimGS)
September 23, 2014, 6:04am
3
Set your NuclearResourceImg
Brush option “Draw As” to “Box” and its “Margin” to 0.
envenger
(envenger)
September 23, 2014, 6:27am
5
Also additionally I want to ask what are the works of other draw types?
Border I know. difference between image and box?
envenger
(envenger)
September 23, 2014, 10:22am
6
It doesn’t worked. It worked for a second but now it still is getting stretched.
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Fill)
[
SNew(SBox)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.WidthOverride(16)
.HeightOverride(16)
[
SNew(SImage)
.Image(&GalaxyHUD->NuclearResourceImg)
]
]
And I have set my brush type to box.
TimGS
(TimGS)
September 23, 2014, 1:36pm
8
Unfortunately, I couldn’t reproduce your issue. I created SCompoundWidget with code like yours:
ChildSlot
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(SBox)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.WidthOverride(64)
.HeightOverride(64)
[
SNew(SImage)
.Image(&TestStyle->ContentBoxBrush)
]
]
];
But my texture stretches fine:
envenger
(envenger)
September 23, 2014, 2:19pm
9
I am compressing the texture not stretching.
Also the overlap slot is inside a horizontal box…
+ SVerticalBox::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Fill)
[
SNew(SBox)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.WidthOverride(16)
.HeightOverride(16)
[
SNew(SImage)
.Image(&GalaxyHUD->NuclearResourceImg)
]
]
+ SOverlay::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Fill)
.Padding(FMargin(20,0,0,0))
[
SNew(SBox)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(STextBlock)
.Font(FSlateFontInfo("Veranda", 9))
.ColorAndOpacity(FLinearColor(0.4, 0.4, 0.4, 1))
.Text(NuclearResource)
]
]
]
TimGS
(TimGS)
September 23, 2014, 2:57pm
10
Sorry I misstyped. I decrease the size too. As you can see my texture is 256x256 and I put it in 64x64 box. I’ll try your code and see what happens.
UPDATE: I tried your model with Vertical Box but still wasn’t able to reproduce the bug.
envenger
(envenger)
September 26, 2014, 2:23pm
11
Hmm what should I do then any idea? Rewrite it?
Also I think you should test it in game. When i first click, the tooltip first appears right then I guess after 1 tick the texture stretches out.
Also My whole thing is placed inside a SCanvas.
envenger
(envenger)
September 26, 2014, 2:39pm
12
TimGS
(TimGS)
September 26, 2014, 3:39pm
13
I’ll try it today/tomorrow.
TimGS
(TimGS)
September 29, 2014, 1:51am
14
OK, here’s update. I run your code and everything works.
But I made a slight edit. I didn’t use FSlateBrush from HUD like you do, I used the FSlateBrush from my style instead.
const struct FTestWidgetStyle* MyStyle = &FTestStyle::Get().GetWidgetStyle<FTestWidgetStyle>("DefaultStyle");
and
SNew(SBox)
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.WidthOverride(16)
.HeightOverride(16)
[
SNew(SImage)
.Image(&MyStyle->TestBrush)
]
Try to use style. Maybe that’s the case. I guess widget styles GetResources
function has something to do with this. Here’s a good tutorial of how to make a style system if you need it: MinaLien.com is for sale | HugeDomains Also ShooterGame is a great example.