I create and attach some actor components at runtime and destroy them later when playing.
I would like to see during runtime in PIE what components an actor has.
I already tried to display the components by checking the Show Actor Components in the View options of the Details panel, but it seems to only display scene components, and to not refresh the view correctly (I have to check then uncheck Selected Actor Only for the spawned actor to display all their scene components).
Is there a way to do display them?
can you tell me you are using C++ or Blueprints ?
If you are using C++, you can create a method to show the existing Components in your Actor. You can use the method GetComponents to get all Components of the class UActorComponent because all the Unreal Engine's components inherit from this Class. And then you can check their classes and print the name and the class for example.
This is an example of code :
void AMyActor::ShowMyComponents() {
TArray<UActorComponent*> MyArray;
GetComponents(UActorComponent::StaticClass(), MyArray, true);
for (auto element : MyArray) {
UE_LOG(LogTemp, Error, TEXT("Component : %s is from class : %s"), *element->GetName(), *element->GetClass()->GetName());
}
}
you can call this method for example in BeginPlay() or in Tick() or anywhere you want and it will show you the components of your actor.
Related
I'm using unreal blueprint of datasmith to load revit model in runtime. but i don't know out how to emit callback when the model has been load and rendered.
the "Datasmith Destination Actor" has a property of progress, i try to watch that property but no luck.
First, the end value is not 1 but 1.396324 ,
Secondly, event when progress reached 1.396324 the hierarchy has not been rendered completely.
watch on datasmith runtime actor
I'm attempting to dynamically add Manipulation Events to a ManipulationHandler that is being added to child objects of a parent. The parent object will be what the user is inspecting, but the user will be able to grab parts off of the parent and inspect them more closely. (i.e. you can look at an engine (parent object), but if you want to inspect the pistons (child objects) you can grab them and look at them)
Instead of having to go into every child object and manually add it in Unity I'd like to be able to add the parent object and just procedurally add the ManipulationHandler and ManipulationEvents on start or awake.
So far I have the following code for adding the ManipulationHandler script, but to add the ManipulationEvent I'm not sure how to set up the pointers so I can use the script and function I want from the source:
gameObject.AddComponent<ManipulationHandler>();
ManipulationHandler handler = gameObject.GetComponent<ManipulationHandler>();
ManipulationEvent newevent = new ManipulationEvent();
ManipulationEventData eventdata = new ManipulationEventData();
eventdata.ManipulationSource = gameObject;
The program works when I grab the objects, but I'd like to add manipulation events when I grab them so I can display additional data.
I see there's a getter and setter for Pointer in ManipulationEventData, but I'm not sure how to instantiate IMixedRealityPointer and how to get it to work. I'm also not sure if that's the object I actually need to accomplish what I'd like to accomplish.
I apologize in advance if I've missed something obvious. I'm new to MRTK.
Thanks!
The ManipulationHandler has four callback events among them OnManipulationStarted and OnManipulationEnded you can simply add listeners to. (see UnityEvent.AddListener)
Unless I understood your question wrong you don't have to instantiate any IMixedRealityPointer. You don't create the event data yourself but rather the ManipulationHandler feeds these events with the current event data including the interacting pointer information. The ManipulationHandler uses OnPointerDown and OnPointerDragged and OnPointerUp via the IMixedRealityPointerHandler interface in order to manage the interacting pointers and invokes the according events where needed.
Instead of using AddComponent followed by GetComponent directly store and use the return value of AddComponent which will be the reference of the newly added Component. MRTK also has an extension method
T EnsureComponent<T>(this Component component) where T : Component
so that you can simply use e.g.
var handler = this.EnsureComponent<ManipulationHandler>();
which internally first checks whether the component already exists, and if not it adds it.
Note that in order to enable near interactions you will also need a NearInteractionGrabbable so you should add this one too.
You also will have to make sure that your objects have some sort of Collider attached to the same GameObject as the NearInteractionGrabbable.
...
gameObject.transform.EnsureComponnet<NearInteractionGrabbable>();
var handler = gameObject.transform.EnsureComponnet<ManipulationHandler>();
handler.OnManipulationStarted.AddListener(HandleOnManipulationStarted);
handler.OnManipulationEnded.AddListener(HandleOnManipulationEnded);
...
/// <summary>
/// If you need it later you need to store the pointer since unfortunately in
/// OnManipulationEnded the <see cref="ManipulationEventData.Pointer"/> is null
/// (no idea why they do it this way :D )
/// </summary>
private IMixedRealityPointer _pointer;
private void HandleOnManipulationStarted(ManipulationEventData eventData)
{
_pointer = eventData.Pointer;
// whatever shall happen when manipulation started
}
private void HandleOnManipulationEnded(ManipulationEventData eventData)
{
// whatever shall happen when manipulation ended
}
Note: I am not sure if this thing you are trying to achieve is possible with this architecture ... it is very possible that nesting various ManipulationHanlder leads to strange behavior here and there. Especially very small parts will be almost impossible to grab ...
Is it possible to dynamically create objects or modify them on run-time ?for example,on button click,another button created or change number of lines of a road?
When I write this code for a button Action,in run-time
road123.setBackwardLanesCount(3);
I get error below:
root:
road123: Markup element is already initiated and cannot be modified.Please use constructor without arguments,perform setup and finally call initialize() .function
You'll get that error with any object you attempt to create at runtime using a parameterized constructor. If you create the object with a simple constructor (just "()") and then set all of the parameters individually, you won't run into that issue. Check the Anylogic API for specific information about the object you are using, because some require you to call .initiliaze() on that object after setting all of it's parameters if you created it using a simple constructor. Furthermore, if you want to add the object to the screen at runtime you'll need to add this code to the function that creates it:
#Override
public void onDraw( Panel panel, Graphics2D graphics) {
obj.drawModel(panel, graphics, true);
}
where obj is replaced with the name of the object you created dynamically.
Using Vala 0.30, how do you find a GTK child widget by name?
The main code calls a function to set up the application layout:
text.application_layout ();
The function creates the window and layout boxes.
class Example : Gtk.Window
{
public void application_layout ()
I want unrelated code to place content in some of the boxes. In C + GTK I could define the window as a global variable and any code could find a child box then add content. I cannot find a working equivalent in Vala.
Jen suggested using Container.get_children(). I will experiment with that. In the previous C code, the get_children approach produced thousands of children when a grid was populated.
Some Web pages show Vala classes with public strings. Vala will not compile the examples of a class when the public variable is a GTK widget. I also tried a dozen variations that work in other languages and fail in Vala.
Finally I found a way to have a public GTK widget that can be found by other code. The following compiles. All the online examples are slightly different and fail to compile in the current Vala.
class Example : Gtk.Window
{
public Grid example_grid = new Grid ();
public void application_layout ()
If this is the only option, I will have to make many items public public.
I will still have the problem of finding the last child in a variable length set of children, something like the last label added to a box or the last row added to a grid. I would like to label items in a long list with a name like last then find it direct instead of reading through a thousand children every time.
Another update. The following grid definition works from within the class. It works from other methods of the class when called within the class.
class Example : Gtk.Window
{
public Grid example_grid;
this.directory_grid = new Grid ();
My main code has var example = new Example(); and passes the example object to other code that needs user interface elements. The other code can then access example.example_grid or a method that updates example.grid. This means changing the other code to accept the example object.
I found then lost a page showing how you can access the main window object without having the object passed to the function. If I can find that again, it would let me access example.example_grid without having to change the code to pass the example object. This is getting close to a solution.
Is there any idea wich allows me using layouts declared in MyApplication.java from other classes and functions.
I tried put them in parameters it works but it becomes very complicated
For example xhen callin a function named Y in function X I have to pass all layouts on parameters like this:
X(layout1,layout2,layout3,layout4)
{
Y(a,b,c,layout1,layout2,layout3,layout4)
}
I tried to use a class named uiHelper but it didn't works
You can take a look at Blackboard addon for vaadin.
https://vaadin.com/addon/blackboard
From that page:
Sometimes, having a deep component hierarchy poses a problem, when you need to inform a component high up in the tree that something happened deep down below. You normally have one of two choices - either pass the listener all the way down the hierarchy, leading to more coupled code, or let each component in between be a listener/notifier, passing the event all the way back up. With the Blackboard, you can register any listener to listen for any event, and when that event is fired, all the listeners for that event are triggered. This keeps your components clean and rid of unnecessary boilerplate code.
For your example, you can create a LayoutChangeListener and LayoutChangeEvent.
MyApplication can then implements LayoutChangeListener and when a LayoutChangeEvent is fired, you can change your layout without passing it around.