Download

Rama's UMG Tutorial: Create a Scrollable List of Buttons From a Dynamic Array

You’re welcome DotCam, great to hear from you!

Yea UMG is amazing!

if you go to the function node and click to add a new output variable, you can then type in the word “Object” into the search filter

I admit it too me a while to find it too! I had to end up using the method I describe just above, of using a search filter.

The search filter method definitely works!

Here’s a pic!

efa0ff24104348c6fa689b8687cc84910d018958.jpeg

[FONT=Comic Sans MS]:heart:

Rama

Aha!
Thank you very much :slight_smile:

Hee hee!

:slight_smile:

Rama

I actually asked a question earlier on the forum but I believe this is actually close to what I am looking for. I am trying to install an image border around my Hud using the widget blueprint section. I already have a decent blueprint thanks to a tutorial I found. I found a section that says image and a place where i can install an image, I have already gotten the checkered box to show up in game, just need to replace that with an image. I assume it’s something to do with the blueprint.

and here is the blueprint (I don’t need the floats yet, I will plug those in later.)

Edit: sorry wrong blueprint and i plugged one in just to show where it would be going, I believe the object return value needs to go into my hud interface somewhere but I can not for the life of me figure out where

**
Right Click->User Interface->Slate Brush Asset**

Hi there!

Have you created a Slate Brush yet for your image?

Right click in content browser -> Slate Brush

then open that asset, and you can set the image, please note you can tile the image if you want

Then go back to your Widget BP and now you can apply the image!

Let me know if that works!

Rama

Yes that work, but i was under the impression that black worked as a transparency. Am I wrong? because I have a black background for the bar, thinking that that would be invisible to the player.

If you import a Texture2D that uses an Alpha channel (32 bit TGA file), then you will get transparency in the Slate Brush in UE4 :slight_smile:

Rama

lol, thank you, I had kinda figured out how to do that, I sort of have a habit of asking questions and then as soon as I ask the question on here I find the answer. we imported an alpha from photo shop and it worked out fine. It looked weird before I created a slate brush, but when I did, It looked like a normal alpha. but I do have one question, mostly because you seem to be the only one answering my questions about the widget blueprint editor and you know what your doing, I had created the blueprint and saved yesterday, I came back and my blueprint was gone (I know I saved). So after trying to find it and being unsuccessful, I decided to draw up a new one, but for some reason I cannot find the Add To Viewport node anywhere? Any ideas why?

Where are you trying to Add To Viewport? Try in Level Blueprint or in your My Character BP !

Also I think a lot of this is going to be vastly improved in the near future when 4.5 comes!

:heart:

Rama

**New UMG Node for my Victory BP Library

Get All Widgets of Class

Ideal for UMG Level Transitions**

I needed this node for Solus and so I am now sharing it with you!

The issue was that I could not save a reference to my new widget because it is loaded and then a level change occurs which resets all my HUD variables.

So I needed to access the widget after it was created dynamically, not relying on stored references within the HUD class.

I also did not want to have to store a reference to it in my Game Instance class cause then that leads to garbage collection issues.

I had to make the node for my own use and I have tested it as working in Solus!

**Now you can retrieve an array of any type of UMG widget instances in your game at any time!
**


**Victory BP Library Download**

https://wiki.unrealengine.com/File:VictoryPlugin.zip

C++ Code

Here’s what my C++ for this node looks like!



void UVictoryBPFunctionLibrary::GetAllWidgetsOfClass(UObject* WorldContextObject, TSubclassOf<UUserWidget> WidgetClass, TArray<UUserWidget*>& FoundWidgets)
{
	//Prevent possibility of an ever-growing array if user uses this in a loop
	FoundWidgets.Empty();
	//~~~~~~~~~~~~
	 
	if(!WidgetClass) return;
	if(!WorldContextObject) return;
	 
	UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject);
	if(!World) return;
	//~~~~~~~~~~~
	
	for(TObjectIterator<UUserWidget> Itr; Itr; ++Itr)
	{
		if(Itr->GetWorld() != World) continue;
		//~~~~~~~~~~~~~~~~~~~~~
		
		if(Itr->IsA(WidgetClass))
		{
			FoundWidgets.Add(*Itr);
		}
	}
}



**Pic**

![GetAllWidgetsOfClass.jpg|1280x960](upload://k3rJSJemWVjAQ9p7eXZQVNYeJAl.jpeg)

Enjoy!

Rama

Bump for those who have not seen this!

Rama

Hey Rama, is there a way to implement this in C++? I extended UserWidget to my C++ project and all I would like to do is add buttons to my ScrollBox via C++.

Best

Rather than trying to use UMG in C++ I’d recommend taking advantage of BlueprintImplementable Events to tell UMG whatever you want it to do from C++!

This way you can do all the button creation logic in C++, and just send the parameters to BP / UMG to build and initialize the buttons.

Wiki on BP Implementable Events

:slight_smile:

Rama

Hi rama,
Thank you to your guide but I have a problem. How can I work with these buttons now? How can I make them “interactible”?

Thank you so much

Lorenzo

Thanks this is just what I need right now!

I feel a little bad resurrecting a necro thread, but it’s such a good post, I don’t mind that much!

I’m trying to retrieve values in variables assigned to the dynamic objects (the buttons). However I can’t seem to properly reference back to my main blueprint (which is not my character BP). When I try to reference back to my “characterSheet” BP, the node asks me for another target (what the heck?!).

Humor me if you will:

  1. I have an array of IDs (WPs) which I am parsing out any that repeat in a second array of IDs, just to ensure duplicating isn’t possible.

  2. After that I pass the ID(s) as a Name to a table look-up, create an instance of the widget button/text, assign an ID to that button, set the text value, and return to the rest of the loop

  3. The loop repeats after I assign the button as a child to a Vertical Box element in the main UMG BP.

  4. I have verified everything works properly up to this point, as I’m able to see the buttons and text populate the screen as I desired, and when I click one, I can “PrintString” to the screen and verify the ID is correct.

So the question is: How do I get the value “ClickedButtonIDPublic” back to the “CharacterSheet” BP? I feel like this is so stupidly obvious, but I’m hitting a brick wall.

Update: I got an answer to my question. I didn’t understand the proper application of event dispatchers. I do now. Yay.

Hello ! First thank you for this tutorial, so helpful !

Forgive me if my question is stupid, but I am new to UE…

When creating addlistitem (checkboxes in my case) I need to add another data (visibility). I tried to nest a loop, create another function but nothing worked…

Where am I wrong ?

56d6b76f8fd4b1bbe2dd18a028f369051d96a562.jpegb17e2e6ca70382827057a267f187699fbf899f11.jpeg

Thank you in advance !

OK someone told me how to do: use an array of a struct

c5d4170b72bc70b6719d82f89ce1ce52d7680bd0.jpeg
71d2c5a18cb419de21c1f7a45817999a8d0d486e.jpeg

I can’t believe this… RAMA saves me once again. You are a legend Rama!