Download

[SOLVED] Access Variables from Blueprint in Content Browser

Problem: Can’t access variables from UBlueprint*.

*BP_First inherit from FirstClass (C++). *There is InstancedMeshComponent created in FirstClass.
*BP_Second inherit from SecondClass (C++). *

I need, from Second Class access FirstClass InstacedStaticMesh components. Is it possible to do?

I, get UBlueprint*, with this:


UBlueprint* FoundObject = FindObject<UBlueprint>(nullptr, *PackageName, false );

I, tried to use:


UProperty* PropertyName = FoundObject>GetClass()->FindPropertyByName(PropertyName);

Sorry, for noobish question again.

It is possible but it should be avoided as it is very cumbersome. Keep the flow of information from C++ to BP and your life will be much easier. Whatever your task is I bet it can be solved quicker without trying to access the Blueprint created variable.

Thanks for reply.

Variable is created in C++ class. And, i need from one blueprint access another blueprint component. I need to copy that component.

Maybe it would possible to cast somehow FirstClass from UBlueprint.

If you have a pointer to FirstClass to work from, you should be able to do:



//inside SecondClass somewhere...
//assuming you have AFirstClass* firstClass from somewhere, like GetAllActorsWithTag(), passed in from collision, set on a property from the editor, etc...
UInstancedStaticMeshComponent* component = firstClass->FindComponentByClass<UInstancedStaticMeshComponent>();


if I understand you correctly. No need for UBlueprint/UProperty magic. Where you get the pointer to FirstClass from depends on your setup.

Thanks for reply.

I don’t have AFirstClass*

I get UBlueprint* from PackageName, and i dont know how to cast, or get AFirstClass from UBlueprint* or** FindObject<>().**


UBlueprint* FoundObject = FindObject<UBlueprint>(nullptr, *PackageName, false );

This question doesn’t make sense;
UBlueprint has nothing to do with this, just get a pointer to an instance of your target class and access it’s mesh from there.

But, I need to access Blueprint Classes which is in ContentBrowser.

No you don’t need it that way…
Use “GetDefaultObject” functions for that.

Thanks BrUnO XaVIeR.