I have a UI widget elevatorButton6. When player press the button on this widget, I want to launch a bluerint bp_elevatorButton6, but I can't cast to it
Widget:
Here I use interface bpi_elevatorButton:
On your GetAllActorsOfClass drag a node from Array and use GET node (with index 0). If you have only 1 BP named BP_ElevatorButton6 spawned in world you are sure that index 0 will return that object, if you have more then 1 it will return first that was found. The node from GET will go into Object node in CastTo BP_ElevatorButton6
EDIT: corrected some typos
Related
I have the following situation I need an answer to:
I have a parent object with children. These children all have unique meshes. Whenever these children are selected in the SceneView, the parent needs to be selected in stead. The children should never have their inspectors exposed (not even a fraction of a second).
How do I do this?
There are two possible solutions that I have come up with which are not the solution I wish to go for.
First being using [SelectionBase] attribute on the parent object. This work perfectly, but only once. The first time the child is selected, the parent gets selected. However, when I click the child again, it still gets selected.
Second solution was to react on Selecten.onSelectionChanged. This however is too slow. I can set the selection to the parent if a child gets selected, but the child gets exposed for a few frames still.
Is there an instant solution to this which can guarantee me the functionality of SelectionBase, but then every time in stead of only the first time I click it?
Thanks in advance! :)
I have found a way to do exactly what i want. I combine the [SelectionBase] attribute with a piece of code in the editor OnSceneGui.
First add the [SelectionBase] attribute to your class
Second add this code to its editor class
private void OnSceneGUI()
{
HandleUtility.AddDefaultControl(0);
//Get the transform of the component with the selection base attribute
Transform selectionBaseTransform = component.transform;
//Detect mouse events
if (Event.current.type == EventType.MouseDown)
{
//get picked object at mouse position
GameObject pickedObject = HandleUtility.PickGameObject(Event.current.mousePosition, true);
//If selected null or a non child of the component gameobject
if (pickedObject == null || !pickedObject.transform.IsChildOf(selectionBaseTransform))
{
//Set selection to the picked object
Selection.activeObject = pickedObject;
}
}
}
This allows the first pick to select the component. From then on, only when you select non-child objects in the scene, selection will actually change.
Situation
I have a variable called number = 0 in my stateful widget in the second screen. Now, when a plus button is pressed it increases by 1 every time. Now when I go to first screen and come back to the second screen the variable again starts from 0 which I don't want.
Needed
When came back to second screen from first screen. I should have the updated variable.
How can I do that?
Try to create a static variable instead of a normal variable.
You can also try initializing the static variable in the first screen and pass it as an argument for better control.
But if you want the variable to be same even after reopening the app, you will have to save it to internal memory.
Hope it works!
I am trying to create match-the following using flutter. I got the source from which the swiping action started by the onPanStart property of GestureDetector by accessing the details.localPosition.
I need to find the destination point as well. But the onPanEnd property does not have details.localPosition.
How can I find the destination point? That is, where my swiping action stopped.
There is no property to find the localPosition in the onPanEnd parameter.
Instead declare a local variable in the class. Update the with details.localPosition inside onPanUpdate parameter.
Clearly when it ends, the variable contains the last updated value.
In a simple level I have a trigger box with event dispatcher that is called on event ActorBeginOverlap. I have in the same level a cube blue print and I want to assign the event dispatcher of the trigger box to the event BeginPlay of the cube so I tried like in the picture but it does not work so what is the correct way to do this ?
you need to set the object you want to cast to MyTriggerBox_Blueprint
You have to get which instance of that triggerBox you want, If you have 50 of them in a level, you have to specify which one you want to cast to. If you have only 1 of them in a level and you want to only talk to that one then use GetActorsOfAllClass then get( a copy) 0 of that array and plug it in as the object
I'm creating a GUI inventory widget for the player, basically I have created the widget, it shows, I want to toggle the widget on and off, what I have now is, I can press the inventory key and it shows, on the A flip flop, but when for the B flip flop, it doesn't hide the inventory as it should be, although it prints the string, its not removing the widget as it should be, what should I add to my player blue print?
In your code on both sides of the flip-flop you are creating the widget, make sure the widget you are trying to hide is the one you created.
For that, remove the "Create Inventory Widget" node from the B part of the flip-flop and connect the "Set Visibility" node 'target' to the "Create Inventory Widget" 'return value' located in the A part of your flip-flop.
It's also recommended to save it as a variable to avoid confusion in your code if you ever need to something with the widget visibility again.