x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Can I rotate a text element drawn within NativePaint override?

I want to draw various text elements within the space of my custom UMG widget. As far as I can see, Slate layout transforms don't support rotation, so it would have to be accomplished with the render transform. However, FSlateDrawElement::MakeText doesn't provide any rotation parameters either, and there doesn't appear to be a way to manually modify the render transform of an element.

Rotating the widget itself is not an option as only certain text elements within it should be rotated.

What's the best way to achieve this?

Product Version: UE 4.8
Tags:
more ▼

asked Jul 12 '15 at 08:04 PM in Using UE4

avatar image

kamrann
2.1k 83 33 119

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I discovered that you can use the overload of FGeometry::MakeChild taking a render transform, then pass a paint geometry created from the result into the MakeText function. It seems to work, but I don't know if it is the correct approach and I still have issues with strange clipping behaviour.

more ▼

answered Jul 21 '15 at 04:30 PM

avatar image

kamrann
2.1k 83 33 119

avatar image MugenCity Aug 31 '15 at 03:10 AM

Do you mind showing us how you managed this? I am running into the same issue.

Cheers, Mugen

avatar image kamrann Aug 31 '15 at 08:27 PM

Sure. Something like this.

 auto RotationTransform = FSlateRenderTransform(FQuat2D(SomeRotation));
 auto TextGeometry = InGeometry.MakeChild(
   TextSize,
   FSlateLayoutTransform(),
   RotationTransform,
   FVector2D(0.0f, 0.0f)
   );
 
 FSlateDrawElement::MakeText(
   OutDrawElements,
   Layer,
   TextGeometry.ToPaintGeometry(),
   Text,
   FontInfo,
   ClippingRect,
   ESlateDrawEffect::None,
   FontColor
   );

You will likely have trouble with the clipping rect, I still haven't found a proper solution and am unsure it's even possible with the way Slate clipping is implemented. If you find stuff getting clipped you can just pass in an arbitrarily large clip rect to MakeText, but then you have to live with text not being clipped when it should be (ie. parent widget boundary). I think this could be worked around by using a scissor rect too, but I haven't dug into that yet.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question