I used the tutorial at https://forums.epicgames.com/threads/817252-Creating-Menus-Buttons-Using-Canvas to create a menu scene for my game i modified it so i could toggle it on/off and gave it a black background but pressing the button i have created does nothing. TheAgent says he was able to implement the button preforming an action by adding this to his tutorial
function CheckBounds(float MousePositionX, float MousePositionY)
{
local float FinalRangeX;
local float FinalRangeY;
if(bStatic == true)
return;
if(bIsActive == true)
{
FinalRangeX = XT + Width; //From the X position add to that the width to create a value starting from the X position to the legnth of the object.
FinalRangeY = YL + Height; //From the Y position add to that the height to create a value starting from the Y position to the height of the object.
//CheckMousePositionWithinBounds
if(MousePositionX >= XT && MousePositionX <= FinalRangeX && MousePositionY >= YL && MousePositionY <= FinalRangeY )
{
//`log("Within Bounds");
bIsHighlighted = true; //Highlight Object (Switch UV Texture IDx)
foreach ThisWorld.AllActors (class'UHUD', HUD)
{
if(HUD.PendingLeftPressed == true) // this was changed from if (bClicked == true)
{
`log("Clicked Button");
ButtonClicked(Tag); // this was added
}
}
}
else
{
bIsHighlighted = false;
}
}
}
and
function ButtonClicked(string ETag)
{
foreach ThisWorld.AllActors (class'UHUD', HUD)
{
HUD.DoButtonAction(ETag);
}
}
which does not work for me as i get an error stating that foreach requires a iterator, but my understanding is that class object does not have a reference to WorldInfo or Actor so iterations cant be used. (and of course if im wrong correct me ) if someone could point me in the right direction for getting my button to preform actions/commands that would be awesome!