Data structure passed to widget

I have a data table and a data structure properly set up. I am spawning cylinders within my level and the cylinders are injected with the data from the data table. I would like to create a widget that as soon as I click a cylinder, it demonstrates the data from the data table.

Any advise on how to create this is appreciated.

Thank you!

so you’d need to make the cylinder UI clickable, then within your structure add another variable (static mesh/bp… whatever your cylinder is)
you’re going to want to get the data table and get the new variable and check it against the mesh you’ve just clicked.
So upon clicking the mesh you SET (e.g. SelectedCylinder)
You get your array of cylinders and with a for each loop with break, check using an if statement if the current cylinder from the array == the selected cylinder, if its true connect that to the break and then on completed you can get the row name from your data table and now you know which row name contains the correct data

another way to do it, rereading what you’ve already done, assuming you’ve made a blueprint with a cylinder in it and the same variables as in your structure and upon spawning your cylinder you set the data from that row to each of the respective variables in your cylinder bp… then upon clicking the cylinder you could just cast to the ‘cylinder_bp’ use the selected cylinder_bp as the target and get the variables from there (the cylinder_bp will need each variable to be instance editable)

This is the Blueprint I have created.

Cylinder and metadata posted by anonymous | blueprintUE | PasteBin For Unreal Engine

I cannot pass the As BP Cylinder Actor to the FIND and KEYS… This is driven from another widget I have previously created that had the Get Datasmith User Data function and it worked like a charm…

Any further ideas are welcome!

So you are spawning cylinders in the level and in doing so you are ‘injecting’ them with the data from the datatable (lets assume this is done correctly and you don’t need to show it) But it would be useful to know how that data is stored… is each cylinder a blueprint with variables populated by the data table? can you not just:

Better yet, an example of selecting a cylinder, getting the variable in that specific cylinder, setting it as the current ‘RandomVariable’ in the GI, retrieving it from the GI and binding it in the UI:




I believe it is better if I explain what I have done so far, that will give you a better picture.

I have created a cylinder actor (BP_CylinderActor) that has a Variable as a Data Structure
image
image

I have also created a Data Table (DT_DegradedBuildings) and a Data structure (DS_DegradedBuildngs). This is the data that is loaded in runtime and injected within the spawned cylinders.

I am trying to push the data from the spawned cylinders to a widget so that when you click the spawned cylinder it presents the data. For the widget, I have created three widgets to compile the one needed.

One is the DataTable_Row that contains two text boxes ‘Key’ and ‘Value’. These contain a number of variables
image
Then I have the DataTable_Information which contains the setup of the widget

DataTable_Information widget posted by R4k00n | blueprintUE | PasteBin For Unreal Engine

This also contains a variable

image

And finally the widget actor (DataTable_InfoActor) that brings all these together and contains the Blueprint shared in my previous post.

I will try your suggestion separately, however if you have any further tips to share based on what I have already done I am more than happy to listen. Thank you for your support so far!

handle it in your player controller

create widget and save a ref

on LeftMouseButton → GetHitResultUnderCurser → break hit result, get actor, use interface to get structure data, if valid pass it to the widget by the Ref you saved

1 Like

This is what I have so far

Can you please explain how I can pass it to the widget? On my previous blueprint, I created the following:

But I cannot drive the FIND or KEYS to my Cylinder or Data. This used the Get Datasmith User Data, which in my cylinders is now substituted with the Default / Building Data injected to my BP_CylinderActor

ok, none of that makes sense haha

i’ll try keep it simple, in your first pic where you have GetClass() change that to cast to BP_CylinderActor if its valid you can drag off and get the BuildingData, then send it to you WidgetRef

now the widget if you constructed in your player controller and saved the ref will be the WidgetRef

Thank you for this information, how do I distinguish that the data is sent to the widget? What is the exact function that accesses the specific parameters in my actor, pass it on the the widget and display it?

Actor-> CastToBP_CyclinderActor

in future you may want to look into interfaces but for now lets just get this working

This is what I have so far with casting… Please ensure you zoom out to see the entire blueprint…

Blueprint for passing metadata from cylinder to widget posted by R4k00n | blueprintUE | PasteBin For Unreal Engine

Although the Blueprint does not produce any errors, it does not present any information in runtime…

the blue node AsBP_CyclinderActor has access to everything in that class, so drag off that and search for the data you need

Thank you for this information, can you please have a look to my Blueprint?

DataTable_InfoActor posted by R4k00n | blueprintUE | PasteBin For Unreal Engine

I dragged the pin out of the blue node, however still I cannot see anything in runtime.

you’ve got your buildingdata which was the goal, now just sent it to your widget.

i told you earlier to save the WidgetRef on construction, create a function inside the widget called UpdateData, create an input pin of type buildingdata

then in your graph above, right after you Get buildingdatam get your widgetref and call updatedata.

there is soo much wrong with your code above though that if you cant follow this you might be better off start with some basic tutorials, good luck!

I looked further to my code and realised a couple of issues.

Initially, I used some Cesium functions that do not apply to this blueprint as I am not using Cesium data (get property table values from hit and get values as strings). I need to access the Building Data of each cylinder. This is my struggle now.

I did as you mentioned and created a function with UpdateData. I am still struggling to get it to work.

DataTable_InfoActor posted by R4k00n | blueprintUE | PasteBin For Unreal Engine

Resurfacing this discussion as I have been doing a lot of work in the background. I managed to pass the data and I can now see the different values on my widget. However, I am looking into a more efficient way of passing the information to the widget (maybe through loops?)… I start by creating a function that adds the rows through key and value text. Key text should contain the standard data (Address, long, lat, etc) where value contains the actual value (the actual address, the numerical value for lot, lat etc).

Then I pass the info to my widget. The last bit of Blueprint is the following:

Is there a more efficient way instead of adding rows and manually placing the key text? I understand that I have different variable types in my data structure that I need to consider, however how can I use loops effectively to read from the data structure? Any advice is appreciated.