x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[Request] Draw editor event for blueprints and native.

Coming from Unity, one feature they have is an easy way to draw debug lines for custom classes in the editor. Please see OnDrawGizmos and OnDrawGizmosSelected .

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.

Solution:

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.

Product Version: Not Selected
Tags:
more ▼

asked Oct 07 '14 at 10:47 PM in Using UE4

avatar image

invulse
44 2 4 10

avatar image Shadowriver Oct 07 '14 at 10:59 PM

Whats "DebugLine"?

You can use HUD canvas to draw things, some components can be helpful too like Shape Components which you can make them visible during game play if you want

avatar image invulse Oct 07 '14 at 11:05 PM

Consider that you something like a Route which references 2 notes in the scene for positions. The route uses the order of these notes to determine which is the start and end point. A nice thing to be able to do would be to draw an arrow from the first note to the second. Right now there is no good way to do this. Unity makes this very easy by overriding OnDrawGizmos() where you can then just draw an arrow from the first point to the second and any other data you wish to display in the editor only.

avatar image Shadowriver Oct 08 '14 at 03:00 AM

I think you think too much Unity way :p From what you saying it sounds like you want draw a line from Point A to Point B, it does not need to be done same way as in Unity, not to mention what you want sounds impossible in UE4 as you can't draw things per frame, you can only do there with HUD canvas, you need to use components instead. As long it result is what you desired it's ok right?

Maybe try USplineComponent, as i know you can use it to draw lines in 3D

avatar image invulse Oct 08 '14 at 03:19 AM

Well it certainly is possible to draw things per frame in UE4, see DrawDebugLine, DrawDebugSphere, etc, all those have the ability to clear each frame.

Right now whats not possible is to draw things only in the editor while not playing. Unity may not be as advanced in some areas as UE4, but it is lightyears ahead in editor customization and usability, and this is one of the areas where it is simply easier to use and better thought out than UE4 right now.

I did some digging into the editor and found ComponentVisualizers in the editor code. These have the basic idea of what I am looking for where you can draw the anything necessary to visualize the component to the editor SceneView, however there are only a handful of components which take advantage of this, and they are hardcoded into the editor, which is not ideal at all.

avatar image Aussiemandias Aug 30 '16 at 11:09 AM

To bump this,does anyone know if there's a way to show the visualizers when the actor is NOT selected?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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 :

 class FMyDummyDebugVisualizer : public FComponentVisualizer
 {
 public:
     virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override;
 }


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 :

 GUnrealEd->RegisterComponentVisualizer(UMyDummyDebugComponent::StaticClass()->GetFName(), MakeShareable(new FMyDummyDebugVisualizer ));

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.

Cheers, David

alt text

more ▼

answered Nov 01 '14 at 05:19 AM

avatar image

SkurkSE
131 7 11 17

avatar image invulse Nov 01 '14 at 10:12 PM

I remember looking through this at one point. This is definitely useful for C++, which I work in most of the time, however this really doesn't give non-programmers or blueprint focused programmers the ability to do things on the fly. It would be nice if there was a way for people who want to keep most of their work in blueprint, to be able to draw visualization directly in the blueprint graph.

avatar image SkurkSE Nov 02 '14 at 07:54 AM

Yeah. That would be pretty useful. Just wanted to show that it is not necessary to edit any engine code to write your own.

avatar image mpxc Mar 24 '15 at 02:25 PM

I got it working. A couple extra tricks were necessary:

  1. In my project's (projectname).Build.cs file, I had to add "UnrealEd" as a dependency. Otherwise, use of FComponentVisualizer would cause a linker error.

  2. I had to add a ADebugEnabledActor class that extends from AActor. All it has is a virtual DebugDraw function. My route data actor extends from ADebugEnabledActor instead of AActor so that my FDebugVisualizer ( which is registered to my UDebugVisualizerComponent ) can cast its owner to ADebugEnabledActor in DrawVisualization (otherwise the cast will fail) and call its DebugDraw function. Much more complicated than I was hoping, but it works! (if there is a way to simplify any of this, or do away with the extra inheritance please let me know)

  3. You can add something like this to automatically add the debug visualization plugin to your actors (might want to make it editor only or this extra data will end up in your shipped code. or do it later):

UDebugVisualizerComponent* DebugVisualizerComponent = ObjectInitializer.CreateDefaultSubobject(this, TEXT("DebugVisualizer"));

avatar image Paul AtLink Feb 27 '18 at 07:57 PM

After reading up on this I get the idea that it will only display visualizations when the component is selected, is this true? Or is there a way to draw visualizations that will show at all times in the editor?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question