Download

EditorMode Plugin | Best way to only show certain information in the viewport and limit selection?

Hey there,

I’m currently working on an EditorMode to spawn and modify “Vectors” in the Viewport.
The way this works is with EditorUI Buttons that spawn a “StreetVertex” Actor and also connect them to each other.
Currently it looks something like this:

https://puu.sh/tuIC4/0b28da034d.png

These “StreetVertex” Actors are saved in a so called “StreetActor” that is representing a Street.
A Street goes from Junction (Green) to Endpoint (Red) or any constellation of it. The image above shows 3 Streets.
So at this point we have 10 StreetVertex Actors and 3 StreetActors in the scene.

Now this works all quite well, but it seems highly wasteful to use an Actor for the StreetVertex which is basically just a Vector after all.

Why did I still choose an Actor for this?

Because I don’t know how to properly modify a simple Vector and also not to just spawn one.
I could use these 3D Widget Vector things, but that also sounds wrong.

Now another problem I ran into is: I don’t want the user to modify these StreetVertices outside of my custom EditorMode.
Means as soon as I go out of this mode, they should be hidden. That’s not really possible with Actors. Even if I set the to invisiblem outside of the Editor mode, they would still be visible in the outliner.

What did I think about for the solution?

I tried looking into the GeometryMode, as this is hiding and showing the Vertices etc. and also making it possible to selected and modify them.
They simply extended the FVector into their own Class and let the EditorMode forward selection to it. Then some other quirks that result in being able to modify them.
These Custom Vectors are part of the Geometry Cubes, so this could be similar to my StreetActors.

Now the question is: Is there a better way to make positions in the viewport editable and visible only in your custom EditorMode or should I go for copying the way it was solved for the GeometryMode?

Personally I will go GemotryMode way since it’s way flexible than actor method. I use similar method in my mesh tool plugin, each vertex is only visual element, the edmode code is responsibled to handle the actual select and transform. /type from phone/

Sounds fair. Will have a look at it again and see what I can use it for.

Do not spawn Actors with geometry. At most give them a collision box to generate mouse click events (and make them editor only);
To visualize street vertex in viewport, you can use this:

Even without collision it’s not optimal. The debug sphere is fine, it’s more about being able to modify the locations and make them inaccessible in other modes.