Note: In the Get Asset By Path there is only 1 bp test6 and I have verified that it is finding test6. I have also confirmed that the found class for test6 is of type AlphaBrush_BP
As you can see from the code when I cast test6 to AlphaBrush_BP the result fails. What am I doing wrong?
Generally objects need to be in the world in order to be objects. Meaning finding the object by asset really isnât finding an object in the level. If the object(BP) was an editor utility widget, and the widget was running, your code would be fine, because there is an existing object related to the asset that is in existence. But just a normal BP inheriting from an actor lets say, is not going to be valid unless it exists in the world already.
But it does actually find the BP in the editor. I have also tried the Load Asset function which specifically states that it loads an asset from the Content Window. Load Asset | Unreal Engine Documentation
I tried your code. Itâs as I mentioned, you essentially have an Asset Object not an instance of the Object itself (in the level). If you take the class of the object and print it youâll see what I mean.
Try this instead - make an editor utility or editor utility widget.
Can you clarify more specifically what you want to happen, when you say âchange the property of a blueprint in your Content Browserâ? That part doesnât make sense, so weâre all grasping at straws trying to figure out what you want to happen.
So you are correct in that I need to change the class defaults. It looks like it is very easy in python.
import unreal_engine as ue
from unreal_engine.classes import Blueprint
blueprint = ue.load_object(Blueprint, '/Game/DumbActor')
blueprint.GeneratedClass.get_cdo().ChangeMe = 17.0
print(blueprint.GeneratedClass.get_cdo().ChangeMe)
blueprint.save_package()
I just donât understand why it is not easy to do in blueprints. I know there is a function to get class defaults, but I do not see one the allows you to set class defaults.
Do you by chance know the C++ equivalent to the python code I posted? I canât seem to get the syntax correct in C++.
I did use python and the code below worked perfectly.
import unreal
# get the generated class
blueprint_generated = unreal.EditorAssetLibrary.load_blueprint_class("/Game/test/dan_peak.dan_peak")
# from that, get the class default object ( the actual template for the blueprint )
blueprint_class_default = unreal.get_default_object(blueprint_generated)
# set or get properties
blueprint_class_default.set_editor_property("Name", "test")
unreal.EditorAssetLibrary.save_asset("/Game/test/dan_peak.dan_peak")