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"

Material not drawing to UCanvasRenderTarget2D

This draws a line and a material to a UCanvasRenderTarget2D from the delegate triggered by UpdateResource(). The material draws to the screen fine from blueprint but drawing to the texture doesn't appear to work. As the Line and Material are sharing a set of coordinates you should expect to see a Crosshair where the line and bullets are intersecting. However the Material is clearly not there.

The Material tile appears to be added to the Renderbatch correctly so I'm not sure what's going on.

 void UWavesUIElement_MousePointer::DrawElement(UCanvas* C)
 {
     if (IsUsingGamepad())
         return;
 
     FVector2D ScaledSize = GetScaledSize(GetHUD()->ScreenScale.X);
     FVector2D MousePosition;
 
     GetHUD()->GetMouseCoordinates(MousePosition);
 
     Position = MousePosition;
 
     switch (Alignment)
     {
     case EUIAlignment::UIALIGN_Center:
         Position.X -= ScaledSize.X / 2;
         Position.Y -= ScaledSize.Y / 2;
         break;
     case EUIAlignment::UIALIGN_Right:
         Position.X -= ScaledSize.X;
         Position.Y -= ScaledSize.Y;
         break;
     }
 
     if (!PointerMID)
     {
         PointerMID = UMaterialInstanceDynamic::Create(PointerMaterial, this);
         PointerMID->SetVectorParameterValue(FName("Color"), PointerColor);
     }
 
     if (PointerMID)
     {
         FVector2D CoordinatePosition(0, 0);
         FVector2D CoordinateSize(128, 128);
         C->K2_DrawMaterial(PointerMID, Position, ScaledSize, CoordinatePosition, CoordinateSize);
         C->K2_DrawLine(Position, CoordinateSize, 10.f);
     }
 }

alt text

Product Version: UE 4.7
Tags:
more ▼

asked Jun 05 '15 at 08:34 PM in C++ Programming

avatar image

SquidInABox
52 8 8 11

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

1 answer: sort voted first

Typically whenever I resort to posting a question I then solve the problem ten minutes later.

I didn't realize that CoordinateSize is Normalized (I only noticed when I went and fiddled with the DrawMaterial node in blueprint) so my value of 128,128 was FAR too large and the crosshair material was too small to see.

more ▼

answered Jun 05 '15 at 08:43 PM

avatar image

SquidInABox
52 8 8 11

(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