WHAT
Creating tools for repetitive or simple processes is a key factor in speeding up workflow. It’s also easy to think that they require a ton of coding background, time and effort - but that is not always the case. This week we’ll be chatting with our very own Krzysztof about ways to create these tools using Blueprints and Python, and how simplifying the process can empower anyone to pick up the skillset.
Hi, i’d like to make buttons to set light map resolution via editor widget but the only exposed parameters is “get light map reslution” and there is no “set”…
I try to use recorsive “compute lightmap density” till it reach the correct value but it’s not the right way to achive my goal (and also it’s a very wrong way of doing things…).
It will be usefull to have expose at least all the parameters in the details rollout and not only some of them…
Hi, just wondering if the python function decorators (UClass Decorators (Python) | Unreal Engine Community Wiki) are still not recommended as best practices? In the past we had tried to use them for various editor scripts, but because python scripts seemed to be loaded at a much later stage in editor start up cycle, it was causing issues with blueprints. Certain blueprints that were being run at start up wouldn’t have access to these decorated nodes until much later in the cycle and would cause execution errors.
For the time being we’ve been using the Execute Python Script BP node instead and wrapping them in Macros/Functions to ensure compatibility across the board.
Also, I’m wondering if python at any point will natively editable via a more user friendly syntax highlightable window directly inside the Unreal Editor, that way if we enable Developer Mode for python in the Editor Preferences, we can quickly open a script in Editor, make the changes and have them reloaded for testing in BP.
At the moment we’re either copying and pasting code into BP nodes and often just using the output log commands to reload modules as part of the dev cycle and this isn’t the most optimal solution.
I know there are some plugins on the marketplace that allow python editing in editor but the way they work is not like what I have described above. They instead create a Python folder outside of the Game folder at the uproject level and store custom scripts there. We cannot edit python scripts in the Game folder with this plugin.
Really interested to hear back on some of these points. It would definitely ramp up our dev cycles with some of these quality of life fixes.
Hey @wwang.method , sorry, I’m afraid I can’t help with the decorators question at the moment. If I’ll learn something in the future I’ll make sure to get back here and let you know. I can clearly see how it could be useful!
In the livestream I gave a few tips how to make python script development more effortless. I mentioned things like adding the Python Stub to your VS Code projects for syntax highlighting and auto completion, or using importlib to reload your scripts when you run them:
To me, it’s an actually quite comfortable workflow, when you prepare well. I personally don’t think it’s necessary to have the scripts open in the editor. We have great code editors out there, and they are light and have everything you need - do you see it differently? Unfortunately, there are no other shortcuts I know of, but feel free to let me know if my suggestions helped. If not, feel free to let me know what still doesn’t work for you, maybe I’ll be able to come up with something.
We are fairly active in using VS Code going as far as even writing our own VS Code extensions so it is a highly used IDE in our workflow. The ability to write python code rather than copying and pasting code into a limited text area on a BP node or details window can get tedious if you’re just trying to make minor tweaks. We are actively doing the hot reloading stuff as well but more so in the output log console, otherwise our blueprints are needlessly reimporting scripts in production. We also make use of init_unreal python files quite extensively to initialize environment paths where we host our modules as well. For the most part a more robust editor in editor opens up more quality of life improvements. They can be repurposed to editing shader code as well.
Without function decorators right now we just have to have additional steps to setup BP function libraries where we wrap our execute python script nodes with explicit type inputs and outputs in order to make our python libraries more interfaceable from a BP workflow perspective.
An example of in editor scripting can be found here:
With a workflow like this, you can open up stuff like auto hot reload on save.
I havent tested it yet, but I thought about a workaround for that particular issue.
The root cause of the problem is that blueprints are missing the definitions of the python generated nodes because python startup happens last and asynchronously in the editor.
So it might be possible to make python force recompile all blueprints using the python nodes.
create a dummy blueprint class “BP_AutomaticStartupRecompile”
create a python script which filter assets by this class (using the asset_tools)
then iterating through the returned assets, call the compile_blueprint of the BlueprintEditorLibrary
set this script as a python startup script in the project settings
make any blueprint using python uclasses inherit the BP_AutomaticStartupRecompile class.
I can’t test this right now sadly, but in theory this could work.
Are you aware of any way to modify exposed variable defaults (or components) of blueprints directly on the asset level ? (not as actors inside a level)
This is possible on the materials using the set_editor_property functions, but I couldnt find anything for the blueprints exposed variables.
I can give this a try next week. Although it would solve the compilation step, you may still need to rerun some of the construction scripts that cascade for more complex scenarios.
Hi Krzysztof, Tina. I have been studying your demo files. I’ve notices there’s some errors under the Geometry Script BP. When you are trying to call the Bake to Static mesh, the path of the asset, in this case will never exist. (please try the debugging, the image I have attached)
also in the CopyToExistingStaticMesh event, there’s only static mesh asset loading. there’s neither SM_BakedMesh bp spawning, nor setting variable copying.
I hope others not getting confused when checking up those blueprints.
Thanks ! That works really well for variables.
By any chance, would you know how to do that with components instead of variables ?
If I try it on a component, get_editor_property will return None, and set_editor_property will not actually modify the component on the asset.
In my case I’m trying to modify a static mesh component attached to a blueprint.
Thanks a lot for the inputs via YT vidoes. I was wondering whether it works to add a python script which streams some data from a sensor which I could use then to move an actor? I wonder whether it stops the script every time with the new tick and reruns it or whether it shifts back and forth from other tasks to the script? I would like to make the actor move with the real time data transferred. Any ideas, if that works? So that the script does not block the editor while running.
I read before python is not available on run time, but meaning it should work with the editor using ticks, right?
@daltongd Thanks for the python code, that helped. I am developing an Editor Utility Widget that sets variables in non-actor classes like GameMode and Game Instance but the EUW does not seem to connect to those? Right now my work around is very convoluted and cumbersome, getting GameMode class defaults and storing them in their own variables in the EUW, then sending python command (using your script above) to set the variables. This is obviously a terrible way of achieving this. Any ideas?
Heyo!
I have a fix for the problem that Python scripts loaded at a later editor stage.
The fix is quite simple, you can see it in my free plugin in marketplace or in GitHub