UDN
Search public documentation:

DevelopmentKitGemsCanvasKismetNodes
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Unreal Development Kit Gems > Creating Canvas Kismet nodes
UE3 Home > Kismet Visual Scripting > Creating Canvas Kismet nodes

Creating Canvas Kismet nodes


Last tested against UDK Apr, 2011
PC and iOS compatible

Overview


Kismet is an excellent tool when developers need/want to quickly create a working prototype as quickly as possible. This gem adds simple Canvas drawing functionality to Kismet that makes it easy to draw materials, textures and text. This gem is extendable if you require more functionality. A benefit to using this gem over the existing MobileHUD method, is that this method will work for any game type, whether you have your own HUD subclass or not.

HUDKismetExampleCanvas.jpg

HUDKismetSeqEvent_RenderHUD


This Kismet sequence event node is called every time the HUD renders a frame. You can have as many of these as you like, but it is difficult to determine the order of when each Render HUD event is called (consistent within a game, but potentially not consistent game to game).

HUDKismetRenderHUDNode.jpg

Source code

The logic of this sequence event is:
  • When the sequence event is registered, a rendering proxy is created if one isn't found.
  • When a rendering proxy is found, it adds itself to the rendering proxy's rendering sequence array
  • When the rendering proxy is called to render a frame, it calls the Render function within each Render HUD sequence event. The Render HUD sequence event then iterates through each render sequence action and calls the Render function within each one it finds.

HUDKismetSeqEvent_RenderHUD.uc
class HUDKismetSeqEvent_RenderHUD extends SequenceEvent;

var Object PlayerController;
var Vector CameraPosition;
var Vector CameraDirection;

event RegisterEvent()
{
  local WorldInfo WorldInfo;
  local HUDKismetRenderProxy RenderProxy, FoundRenderProxy;

  // Get the world info
  WorldInfo = class'WorldInfo'.static.GetWorldInfo();

  // Abort if the world info isn't found
  if (WorldInfo == None)
  {
    return;
  }

  // Find a render proxy to associate with this render HUD event
  ForEach WorldInfo.DynamicActors(class'HUDKismetRenderProxy', FoundRenderProxy)
  {
    RenderProxy = FoundRenderProxy;
    break;
  }

  // If a render proxy hasn't been found, then create a render proxy
  if (RenderProxy == None)
  {
    RenderProxy = WorldInfo.Spawn(class'HUDKismetRenderProxy');
  }

  // Add this HUD render sequence to the rendering proxy
  if (RenderProxy != None)
  {
    RenderProxy.AddRenderHUDSequenceEvent(Self);
  }
}

function Render(Canvas Canvas)
{
  local int i, j;
  local HUDKismetSeqAct_RenderObject RenderObject;

  // Render output links
  if (OutputLinks.Length > 0)
  {
    for (i = 0; i < OutputLinks.Length; ++i)
    {
      if (OutputLinks[i].Links.Length > 0)
      {
        for (j = 0; j < OutputLinks[i].Links.Length; ++j)
        {
          RenderObject = HUDKismetSeqAct_RenderObject(OutputLinks[i].Links[j].LinkedOp);

          if (RenderObject != None)
          {
            RenderObject.Render(Canvas);
          }
        }
      }
    }
  }
}

defaultproperties
{
  ObjName="Render HUD"
  ObjCategory="ExtHUD"

  MaxTriggerCount=0
  bPlayerOnly=false

  OutputLinks(0)=(LinkDesc="Out")

  VariableLinks(0)=(ExpectedType=class'SeqVar_Object',bHidden=true,LinkDesc="PlayerController",bWriteable=true,PropertyName=PlayerController)
  VariableLinks(1)=(ExpectedType=class'SeqVar_Vector',bHidden=true,LinkDesc="Camera Position",bWriteable=true,PropertyName=CameraPosition)
  VariableLinks(2)=(ExpectedType=class'SeqVar_Vector',bHidden=true,LinkDesc="Camera Direction",bWriteable=true,PropertyName=CameraDirection)
}

Adding the Render HUD sequence event

HUDKismetAddRenderHUDEvent.jpg

HUDKismetRenderProxy


Render proxies are actors created to hook into the PostRenderActor array that is found within HUD.

Source code

The logic of this render proxy is:
  • A helper function (AddRenderHUDSequenceEvent) which adds a render HUD sequence event to its internal array. This is called by HUDKismetSeqEvent_RenderHUD.
  • A single use Tick which adds itself to all of the Player Controller's HUD PostRender actor and sets ShowOverlays to true which is required for PostRenderActors to receive the render call.
  • PostRenderFor is called at the end of the HUD's PostRender call. This propagates the rendering to all the registered render HUD sequence events.

HUDKismetRenderProxy.uc
class HUDKismetRenderProxy extends Actor;

// Has the proxy been assigned to player controllers yet?
var bool HasAddedToAllControllers;
// List of HUD render events
var PrivateWrite array<HUDKismetSeqEvent_RenderHUD> RenderHUDSequenceEvents;

function AddRenderHUDSequenceEvent(HUDKismetSeqEvent_RenderHUD RenderHUDSequenceEvent)
{
  local int i;

  // Check if the Render HUD sequence event already exists
  if (RenderHUDSequenceEvents.Length > 0)
  {
    for (i = 0; i < RenderHUDSequenceEvents.Length; ++i)
    {
      if (RenderHUDSequenceEvents[i] == RenderHUDSequenceEvent)
      {
        return;
      }
    }
  }

  // Add the render HUD sequence event into the array
  RenderHUDSequenceEvents.AddItem(RenderHUDSequenceEvent);
}

function Tick(float DeltaTime)
{
  local PlayerController PlayerController;

  if (!HasAddedToAllControllers)
  {
    // Add the render proxy to all of the local player controllers
    ForEach WorldInfo.AllControllers(class'PlayerController', PlayerController)
    {
      if (PlayerController != None && PlayerController.MyHUD != None)
      {
        PlayerController.MyHUD.bShowOverlays = true;
        PlayerController.MyHUD.AddPostRenderedActor(Self);
        HasAddedToAllControllers = true;
      }
    }
  }

  Super.Tick(DeltaTime);
}

simulated event PostRenderFor(PlayerController PC, Canvas Canvas, Vector CameraPosition, Vector CameraDir)
{
  local int i;

  // Abort if the canvas is invalid, or there is no sequence events to render
  if (Canvas == None || RenderHUDSequenceEvents.Length <= 0)
  {
    return;
  }

  // For each HUD render sequence, propagate the render
  for (i = 0; i < RenderHUDSequenceEvents.Length; ++i)
  {
    if (RenderHUDSequenceEvents[i] != None)
    {
      // Pass the player controller for Kismet
      RenderHUDSequenceEvents[i].PlayerController = PC;
      // Pass the camera position for Kismet 
      RenderHUDSequenceEvents[i].CameraPosition = CameraPosition;
      // Pass the camera direction for Kismet
      RenderHUDSequenceEvents[i].CameraDirection = CameraDir;
      // Pass the render call
      RenderHUDSequenceEvents[i].Render(Canvas);
    }
  }
}

defaultproperties
{
  bPostRenderIfNotVisible=true
}

HUDKismetSeqAct_RenderObject


This is an abstract kismet sequence action that all other render kismet sequence action subclass.

Source code

The logic of this abstract sequence action is:
  • When the Render function is called, it propagates it to all connected children.

HUDKismetSeqAct_RenderObject.uc
class HUDKismetSeqAct_RenderObject extends SequenceAction
  abstract;

function Render(Canvas Canvas)
{
  local int i, j;
  local HUDKismetSeqAct_RenderObject RenderObject;

  // Propagate the rendering call to all other child links
  if (OutputLinks.Length > 0)
  {
    for (i = 0; i < OutputLinks.Length; ++i)
    {
      if (OutputLinks[i].Links.Length > 0)
      {
        for (j = 0; j < OutputLinks[i].Links.Length; ++j)
        {
          RenderObject = HUDKismetSeqAct_RenderObject(OutputLinks[i].Links[j].LinkedOp);

          if (RenderObject != None)
          {
            RenderObject.Render(Canvas);
          }
        }
      }
    }
  }
}

defaultproperties
{
  VariableLinks.Empty
}

HUDKismetSeqAct_RenderTexture


This Kismet sequence action renders a texture onto the Canvas.

HUDKismetRenderTextureNode.jpg

Source code

The logic of this sequence action is:
  • Before rendering, check if Canvas is valid, using either actual or relative sizing, using either actual or relative position.
  • If the user has connected to the Texture Kismet variable node then this overrides the Texture property value
  • Calculate the rendering position
  • Calculate the rendering size
  • Calculate the texture rendering bounds
  • Rendering the texture stretched, rotated or normally depending on various properties that have been set by the user

HUDKismetSeqAct_RenderTexture.uc
class HUDKismetSeqAct_RenderTexture extends HUDKismetSeqAct_RenderObject;

struct TextureRotation
{
  // Amount to rotate the texture in Unreal units (65536 == 360 degrees)
  var() int Rotation;
  // Relative point to perform the rotation (0.5f is at the center)
  var() Vector2D Anchor;

  structdefaultproperties
  {
    Anchor=(X=0.5f,Y=0.5f)
  }
};

struct TextureCoords
{
  var() float U;
  var() float V;
  var() float UL;
  var() float VL;

  structdefaultproperties
  {
    U=0.f
    V=0.f
    UL=-1.f
    VL=-1.f
  }
};

struct TextureStretched
{
  var() bool StretchHorizontally;
  var() bool StretchVertically;
  var() float ScalingFactor;

  structdefaultproperties
  {
    ScalingFactor=1.f
  }
};

// Condition to using actual size coordinates
var bool UsingActualSize;
// Condition to using relative size coordinates
var bool UsingRelativeSize;
// Condition to using actual position coordinates
var bool UsingActualPosition;
// Condition to using relative position coordinates
var bool UsingRelativePosition;
// Condition to using the stretched method
var bool UsingStretched;
// Condition to overriding the blend mode
var bool OverrideBlendMode;

// Texture to render. Overrided if the user sets the texture variable link
var(RenderTexture) Object Texture;
// Actual size to render the texture
var(RenderTexture) IntPoint ActualSize<EditCondition=UsingActualSize>;
// Relative size, to the viewport resolution, to render the texture
var(RenderTexture) Vector2D RelativeSize<EditCondition=UsingRelativeSize>;
// Actual position to render the texture
var(RenderTexture) IntPoint ActualPosition<EditCondition=UsingActualPosition>;
// Relative position, to the viewport resolution, to render the texture
var(RenderTexture) Vector2D RelativePosition<EditCondition=UsingRelativePosition>;
// Rotation of the texture to render
var(RenderTexture) TextureRotation Rotation;
// Coordinates of the texture to render
var(RenderTexture) TextureCoords Coords;
// Color to render the texture
var(RenderTexture) Color RenderColor<DisplayName=Color>;
// Stretched properties when rendering the texture
var(RenderTexture) TextureStretched Stretched<EditCondition=UsingStretched>;
// If the texture is partially outside the rendering bounds, should we clip it? (Only for non rotated, non stretched textures)
var(RenderTexture) bool ClipTile;
// Blend mode for rendering the texture (Only for non rotated, non stretched tiles) (Always overrided for materials on iOS)
var(RenderTexture) EBlendMode BlendMode<EditCondition=OverrideBlendMode>;

function Render(Canvas Canvas)
{
  local IntPoint RenderPosition;
  local IntPoint RenderSize;
  local Texture2D RenderTexture;
  local int UL;
  local int VL;
  local Rotator R;
  local SeqVar_Object SeqVar_Object;

  if (Canvas != None && (UsingActualSize || UsingRelativeSize) && (UsingActualPosition || UsingRelativePosition))
  {
    // Check if the user has set the texture kismet node link
    if (VariableLinks[0].LinkedVariables.Length > 0)
    {
      SeqVar_Object = SeqVar_Object(VariableLinks[0].LinkedVariables[0]);

      if (SeqVar_Object != None)
      {
        RenderTexture = Texture2D(SeqVar_Object.GetObjectValue());
      }
    }
    else
    {
      RenderTexture = Texture2D(Texture);
    }

    if (RenderTexture != None)
    {
      // Calculate the position
      if (UsingRelativePosition)
      {
        RenderPosition.X = Canvas.ClipX * RelativePosition.X;
        RenderPosition.Y = Canvas.ClipY * RelativePosition.Y;
      }
      else
      {
        RenderPosition = ActualPosition;
      }

      // Calculate the size
      if (UsingRelativeSize)
      {
        RenderSize.X = Canvas.ClipX * RelativeSize.X;
        RenderSize.Y = Canvas.ClipY * RelativeSize.Y;
      }
      else
      {
        RenderSize = ActualSize;
      }

      // Calculate the texture width
      UL = (Coords.UL == -1) ? RenderTexture.SizeX : int(Coords.UL);
      // Calculate the texture height
      VL = (Coords.VL == -1) ? RenderTexture.SizeY : int(Coords.VL);

      // Set the position to render
      Canvas.SetPos(RenderPosition.X, RenderPosition.Y);
      // Set the draw color
      Canvas.SetDrawColor(RenderColor.R, RenderColor.G, RenderColor.B, RenderColor.A);

      if (UsingStretched)
      {
        // Render the texture stretched
        Canvas.DrawTileStretched(RenderTexture, RenderSize.X, RenderSize.Y, Coords.U, Coords.V, UL, VL,, Stretched.StretchHorizontally, Stretched.StretchVertically, Stretched.ScalingFactor);
      }
      else
      {
        if (Rotation.Rotation == 0)
        {
          // Render the texture normally
          if (OverrideBlendMode)
          {          
            Canvas.DrawTile(RenderTexture, RenderSize.X, RenderSize.Y, Coords.U, Coords.V, UL, VL,, ClipTile, BlendMode);
          }
          else
          {
            Canvas.DrawTile(RenderTexture, RenderSize.X, RenderSize.Y, Coords.U, Coords.V, UL, VL,, ClipTile);
          }
        }
        else
        {
          // Render the texture rotated
          R.Pitch = 0;
          R.Yaw = Rotation.Rotation;
          R.Roll = 0;
          Canvas.DrawRotatedTile(RenderTexture, R, RenderSize.X, RenderSize.Y, Coords.U, Coords.V, UL, VL, Rotation.Anchor.X, Rotation.Anchor.Y);
        }
      }
    }
  }

  Super.Render(Canvas);
}

defaultproperties
{
  RenderColor=(R=255,G=255,B=255,A=255)
  
  ObjName="Render Texture"
  ObjCategory="ExtHUD"

  VariableLinks(0)=(ExpectedType=class'SeqVar_Object',LinkDesc="Texture",PropertyName=Texture)
}

Adding the Render Texture sequence action

HUDKismetAddRenderTextureAction.jpg

Render Texture properties

  • Texture - Texture to render. This is overrided when the user sets the Texture Kismet variable node.
  • Actual Size - Size to render the texture in pixels.
  • Relative Size - Size to render the texture relative to the viewport resolution.
  • Actual Position - Position to render the texture in pixels.
  • Relative Position - Position to render the texture relative to the viewport resolution.
  • Rotation
    • Rotation - Angle to rotate the texture in Unreal units. 65536 uu = 360 degrees
    • Anchor - Relative position to rotate the texture. 0.5f = Center
  • Coords - Coordinates of the sub texture to render. Leave as default to render the whole texture.
  • Color - Color to render the texture
  • Stretched
    • StretchHorizontal - Allow stretching of the texture to occur horizontally
    • StretchVertically - Allow stretching of the texture to occur vertically
    • ScalingFactor - Modify the stretch scaling
  • ClipTile - Clips the rendering of the tile if the tile is partially offscreen
  • BlendMode - Allows you to override the blend mode, otherwise Canvas will detect the texture type and blend accordingly.

HUDKismetRenderTextureProperties.jpg

Related topics

HUDKismetSeqAct_RenderMaterial


This Kismet sequence action renders a material onto the Canvas.

HUDKismetRenderMaterialNode.jpg

Source code

The logic of this sequence action is:
  • When the Render function is called, check to ensure that the Canvas is valid, using either actual or relative size or using either actual or relative position.
  • Check if the user has set the Material Kismet variable node. If the user is using a MaterialInstanceActor, retrieve material instance constant within it. Otherwise get the material interface set.
  • Calculate the position.
  • Calculate the size.
  • Calculate the coordinates.
  • Platform detection
    • If the platform is mobile or iOS, override the blend mode as defined in the Material. Then revert to the RenderTexture rendering function using the MobileBaseTexture reference stored in the Material if applicable.
    • Otherwise, render the material normally or rotated.

HUDKismetSeqAct_RenderMaterial.uc
class HUDKismetSeqAct_RenderMaterial extends HUDKismetSeqAct_RenderTexture;

// Material to render. Overrided if the user sets the material variable link
var(RenderMaterial) Object Material;

function Render(Canvas Canvas)
{
  local IntPoint RenderPosition;
  local IntPoint RenderSize;
  local MaterialInterface RenderMaterialInterface;
  local Material RenderMaterial;
  local int UL;
  local int VL;
  local Rotator R;
  local SeqVar_Object SeqVar_Object;
  local WorldInfo worldInfo;

  // Check if we're allowed to run on this platform
  WorldInfo = class'WorldInfo'.static.GetWorldInfo();
  if (WorldInfo != None && (WorldInfo.IsConsoleBuild(CONSOLE_Mobile) || WorldInfo.IsConsoleBuild(CONSOLE_IPhone)))
  {
    // Check if the user has set the material kismet node link
    if (VariableLinks[0].LinkedVariables.Length > 0)
    {
      SeqVar_Object = SeqVar_Object(VariableLinks[0].LinkedVariables[0]);

      if (SeqVar_Object != None)
      {
        if (MaterialInterface(SeqVar_Object.GetObjectValue()) != None)
        {
          RenderMaterialInterface = MaterialInterface(SeqVar_Object.GetObjectValue());
        }
        else if (MaterialInstanceActor(SeqVar_Object.GetObjectValue()) != None)
        {
          RenderMaterialInterface = MaterialInstanceActor(SeqVar_Object.GetObjectValue()).MatInst;
        }
      }
    }
    else
    {
      if (MaterialInterface(Material) != None)
      {
        RenderMaterialInterface = MaterialInterface(Material);
      }
      else if (MaterialInstanceActor(Material) != None)
      {
        RenderMaterialInterface = MaterialInstanceActor(Material).MatInst;
      }
    }

    if (RenderMaterialInterface != None)
    {
      RenderMaterial = Material(RenderMaterialInterface);
      if (RenderMaterial != None)
      {
        OverrideBlendMode = true;
        BlendMode = RenderMaterial.BlendMode;
      }

      Texture = RenderMaterialInterface.MobileBaseTexture;

      if (Texture != None)
      {
        Super.Render(Canvas);
      }
    }    
  }
  else 
  {
    if (Canvas != None && (UsingActualSize || UsingRelativeSize) && (UsingActualPosition || UsingRelativePosition))
    {
      // Check if the user has set the material kismet node link
      if (VariableLinks[0].LinkedVariables.Length > 0)
      {
        SeqVar_Object = SeqVar_Object(VariableLinks[0].LinkedVariables[0]);

        if (SeqVar_Object != None)
        {
          if (MaterialInterface(SeqVar_Object.GetObjectValue()) != None)
          {
            RenderMaterialInterface = MaterialInterface(SeqVar_Object.GetObjectValue());
          }
          else if (MaterialInstanceActor(SeqVar_Object.GetObjectValue()) != None)
          {
            RenderMaterialInterface = MaterialInstanceActor(SeqVar_Object.GetObjectValue()).MatInst;
          }
        }
      }
      else
      {
        if (MaterialInterface(Material) != None)
        {
          RenderMaterialInterface = MaterialInterface(Material);
        }
        else if (MaterialInstanceActor(Material) != None)
        {
          RenderMaterialInterface = MaterialInstanceActor(Material).MatInst;
        }
      }

      if (RenderMaterialInterface != None)
      {
        // Calculate the position
        if (UsingRelativePosition)
        {
          RenderPosition.X = Canvas.ClipX * RelativePosition.X;
          RenderPosition.Y = Canvas.ClipY * RelativePosition.Y;
        }
        else
        {
          RenderPosition = ActualPosition;
        }

        // Calculate the size
        if (UsingRelativeSize)
        {
          RenderSize.X = Canvas.ClipX * RelativeSize.X;
          RenderSize.Y = Canvas.ClipY * RelativeSize.Y;
        }
        else
        {
          RenderSize = ActualSize;
        }

        // Calculate the texture width
        UL = (Coords.UL == -1) ? 1.f : Coords.UL;
        // Calculate the texture height
        VL = (Coords.VL == -1) ? 1.f : Coords.VL;

        // Set the position to render
        Canvas.SetPos(RenderPosition.X, RenderPosition.Y);

        if (Rotation.Rotation == 0)
        {
          // Render the material normally
          Canvas.DrawMaterialTile(RenderMaterialInterface, RenderSize.X, RenderSize.Y, Coords.U, Coords.V, UL, VL);
        }
        else
        {
          // Render the material rotated
          R.Pitch = 0;
          R.Yaw = Rotation.Rotation;
          R.Roll = 0;
          Canvas.DrawRotatedMaterialTile(RenderMaterialInterface, R, RenderSize.X, RenderSize.Y, Coords.U, Coords.V, UL, VL, Rotation.Anchor.X, Rotation.Anchor.Y);
        }
      }
    }

    Super(HUDKismetSeqAct_RenderObject).Render(Canvas);
  }
}

defaultproperties
{
  ObjName="Render Material"
  ObjCategory="ExtHUD"

  VariableLinks(0)=(ExpectedType=class'SeqVar_Object',LinkDesc="Material",PropertyName=Material)
}

Adding the Render Material sequence action

HUDKismetAddRenderMaterialAction.jpg

Render Material properties

  • Material - Material to render. This is overrided if the user sets the Material Kismet node.

HUDKismetRenderMaterialProperties.jpg

Related topics

HUDKismetSeqAct_RenderText


This Kismet sequence action renders text onto the Canvas.

HUDKismetRenderTextNode.jpg

Source code

The logic of this sequence action is:
  • When the render function called, check if the canvas is valid, the font is valid, using either non localized text or localized text or using actual or relative positioning.
  • Get the text to render. This can be overrided if the user sets the text/localized text Kismet variable node. If you use either of these, remember to tick the respective check box and leave the field blank.
  • Calculate the initial position based on left and top alignment.
  • Set the font and get the text size.
  • Offset the position based on the horizontal and vertical alignment properties.
  • Render the text.

HUDKismetSeqAct_RenderText.uc
class HUDKismetSeqAct_RenderText extends HUDKismetSeqAct_RenderObject;

// Horizontal alignment options
enum EHorizontalAlignment
{
  EHA_Left<DisplayName=Left>,
  EHA_Center<DisplayName=Center>,
  EHA_Right<DisplayName=Right>
};

// Vertical alignment options
enum EVerticalAlignment
{
  EVA_Top<DisplayName=Top>,
  EVA_Middle<DisplayName=Middle>,
  EVA_Bottom<DisplayName=Bottom>
};

// Condition to using actual position coordinates
var bool UsingActualPosition;
// Condition to using relative position coordinates
var bool UsingRelativePosition;
// Condition to using non localized text (raw input)
var bool UsingNonLocalizedText;
// Condition to using localized text 
var bool UsingLocalizedText;

// Actual position to render the texture
var(RenderText) IntPoint ActualPosition<EditCondition=UsingActualPosition>;
// Relative position, to the viewport resolution, to render the texture
var(RenderText) Vector2D RelativePosition<EditCondition=UsingRelativePosition>;
// Color to render the text
var(RenderText) Color RenderColor<DisplayName=Color>;
// Raw text to render
var(RenderText) String Text<EditCondition=UsingNonLocalizedText>;
// Localization path to get the text from to render
var(RenderText) String LocalizedText<EditCondition=UsingLocalizedText>;
// Horizontal alignment
var(RenderText) EHorizontalAlignment HorizontalAlignment;
// Vertical alignment
var(RenderText) EVerticalAlignment VerticalAlignment;
// Font to render the text
var(RenderText) Font Font;

function Render(Canvas Canvas)
{
  local IntPoint RenderPosition;
  local float TextWidth, TextHeight;
  local String RenderText;
  local SeqVar_String SeqVar_String;

  if (Canvas != None && Font != None && (UsingNonLocalizedText || UsingLocalizedText) && (UsingActualPosition || UsingRelativePosition))
  {
    // Get the render text
    if (UsingNonLocalizedText)
    {
      // Check if the user has set the text variable link
      if (Text ~= "" && VariableLinks[0].LinkedVariables.Length > 0)
      {
        SeqVar_String = SeqVar_String(VariableLinks[0].LinkedVariables[0]);

        if (SeqVar_String != None)
        {
          RenderText = SeqVar_String.StrValue;
        }
      }
      else
      {
      RenderText = Text;
      }
    }
    else
    {
      // Check if the user has set the localized text variable link
      if (LocalizedText ~= "" && VariableLinks[1].LinkedVariables.Length > 0)
      {
        SeqVar_String = SeqVar_String(VariableLinks[1].LinkedVariables[0]);

        if (SeqVar_String != None)
        {
          RenderText = ParseLocalizedPropertyPath(SeqVar_String.StrValue);
        }
      }
      else
      {
        RenderText = ParseLocalizedPropertyPath(LocalizedText);
      }
    }

    if (RenderText != "")
    {
      // Calculate the position
      if (UsingRelativePosition)
      {
        RenderPosition.X = Canvas.ClipX * RelativePosition.X;
        RenderPosition.Y = Canvas.ClipY * RelativePosition.Y;
      }
      else
      {
        RenderPosition = ActualPosition;
      }

      // Set the font
      Canvas.Font = Font;
      // Calculate the size of the text
      Canvas.TextSize(RenderText, TextWidth, TextHeight);

      // Handle the horizontal alignment
      if (HorizontalAlignment == EHA_Center)
      {
        RenderPosition.X -= (TextWidth * 0.5f);
      }
      else if (HorizontalAlignment == EHA_Right)
      {
        RenderPosition.X -= TextWidth;
      }

      // Handle the vertical alignment
      if (VerticalAlignment == EVA_Middle)
      {
        RenderPosition.Y -= (TextHeight * 0.5f);
      }
      else if (VerticalAlignment == EVA_Bottom)
      {
        RenderPosition.Y -= TextHeight;
      }

      // Set the canvas position
      Canvas.SetPos(RenderPosition.X, RenderPosition.Y);
      // Set the text color
      Canvas.SetDrawColor(RenderColor.R, RenderColor.G, RenderColor.B, RenderColor.A);
      // Render the text
      Canvas.DrawText(RenderText);
    }
  }

  Super.Render(Canvas);
}

defaultproperties
{
  RenderColor=(R=255,G=255,B=255,A=255)

  ObjName="Render Text"
  ObjCategory="ExtHUD"

  VariableLinks(0)=(ExpectedType=class'SeqVar_String',LinkDesc="Text",MaxVars=1,PropertyName=Text)
  VariableLinks(1)=(ExpectedType=class'SeqVar_String',LinkDesc="Localized Text",MaxVars=1,PropertyName=LocalizedText)
}

Adding the Render Text sequence action

HUDKismetAddRenderTextAction.jpg

Render Text properties

  • Actual Position - Position to render the material in pixels.
  • Relative Position - Position to render the material relative to the viewport resolution.
  • Color - Color to render the text
  • Text - Text to render. This is overrided if the user sets the Text Kismet variable node.
  • Localized Text - Localized text to render. This is overrided if the user sets the Localized Text Kismet variable node.
  • Horizontal Alignment - Horizontal alignment to render the text.
  • Vertical Alignment - Vertical alignment to render the text.
  • Font - Font to render the text.

HUDKismetRenderTextProperties.jpg

Related topics

Example usage


This Kismet layout is used to generate the screen shot at the top of the gem.

HUDKismetExampleKismet.jpg

Related topics


Downloads


  • Download the content/source code. (CanvasKismetNodes.zip)