[Request] Draw editor event for blueprints and native.
Currently there appears to be no easy way to quickly draw debug lines, or information to the editor scene view that is updated every tick, or atleast every time properties of an actor or component updates. Sometimes I have the need to create actors which have no visual representation but need debug lines, arrows, spheres, boxes or a combination of these to show what they do in the world.
Create an event that is fired in blueprints that is only happens in the editor. This event could happen every tick and the user could decide from there what to draw using DrawDebugLine() or some other function. This could also be applied to components in C++. Components could have an editor only function that the user could override and draw any necessary data to the world.
asked Oct 07 '14 at 10:47 PM in Using UE4
You can do this. What you want to look into is the FComponentVisualizers. It is not as straightforward as the unity OnDrawGizmos but it is more powerfull imo.
This does require you to have a custom component in your BP in order to get it to work, but that could be as easy as creating an empty component called "FMyDummyDebugComponent" or whatever you want. You then create something like this :
in DrawVisualization you can do pretty much anything you want. Look into current implementations in the engine code for examples. You have lots of "DrawOrientedWireBox", "DrawWireCone" type functions to play around with.
The following code will register your visualizer to be called whenever a UMyDummyDebugComponent is selected in the editor :
However there is a trick to it. GUnrealEd will be null at startup unless you set your gameplay module to load after the engine. Do this by setting "LoadingPhase": "PostEngineInit" in the uproject file. Once you have done this you can register at module Startup.
I do this by overloading the FDefaultGameModuleImpl and registering in virtual void StartupModule() override.
Here is an example of my visualizer for our tile definition component. When any blueprint contains components of this type it renders shields where you have setup the properties to have covers. This works well in both blueprint editor and in scene view.
Follow this question
Once you sign in you will be able to subscribe for any updates here