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"

How to add a viewport to custom editor window?

Hello,

I am currently working on creating a plugin for unreal engine. Right now i have the editor window that is created with the plugin but have no idea of where to start regarding adding functionally and a view port to the window. I have looked at extending the editor video as well as other documentation but most if not all of the information is vague and doesnt really explain what I need to do such as what .h and .cpp files i should include as well as functions and classes. Any help regarding the subject would be helpful.

Product Version: UE 4.17
Tags:
more ▼

asked Feb 05 '18 at 08:43 AM in C++ Programming

avatar image

dar0005
13 2 2 4

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

1 answer: sort voted first

You'll need two classes derived from these:

  • SEditorViewport - A slate widget to host your viewport client

  • FEditorViewportClient - A viewport client to handle the input and rendering


Since you already have an editor window, you probably have tabs already in place. Slate widgets would go in these tabs, one of which would be your 3D viewport. So, you'll need to first create a slate widget for your 3D viewport by deriving from SEditorViewport

Override the SEditorViewport::MakeEditorViewportClient() function and provide your own "ViewportClient" implementation. You do this by subclassing from FEditorViewportClient

There is also a class called FPreviewScene. You can create this in the SEditorViewport::Construct function. This is an easy way to manage the actors in your preview scene (it will have its own world)

Search SEditorViewport and FEditorViewportClient in the engine's code from github for examples https://github.com/EpicGames/UnrealEngine

more ▼

answered Feb 05 '18 at 09:04 AM

avatar image

Ali Akbar
691 2 6 8

avatar image intoxicat3 Jul 11 '18 at 02:19 PM

Thanks for info!

I have a problem with my custom ViewportClient - I can't click on actors and move them arround as in Editor or Blueprint Editor. Any advice?

avatar image Ali Akbar Oct 07 '18 at 05:18 AM

I've been recently working on this for another project. You can't move your actors by default. You'll have to implement this logic yourself. You can copy most of the functionality from SLevelViewport / FLevelEditorViewportClient (used in the level editor) or from SSCSEditorViewport / FSCSEditorViewportClient (the blueprint editor). It requires some work but it can be done

Override the following functions in the viewport client and implement them like the way they are done in the level editor or the blueprint editor

 virtual bool InputWidgetDelta( FViewport* Viewport, EAxisList::Type CurrentAxis, FVector& Drag, FRotator& Rot, FVector& Scale ) override;
 virtual void TrackingStarted( const struct FInputEventState& InInputState, bool bIsDraggingWidget, bool bNudge ) override;
 virtual void TrackingStopped() override;
 virtual void AbortTracking() override;

 virtual void ProcessClick(FSceneView& View, HHitProxy* HitProxy, FKey Key, EInputEvent Event, uint32 HitX, uint32 HitY) override;

You'll also need a lot of other supporting code to be copied to your plugin and modified locally for snapping and spawning to work (as they depend on FLevelEditorViewportClient, which you cannot use if you want to host your own world)

avatar image LDOGLONDON Jun 27 '19 at 11:48 PM

Ali Akbar thanks for the info, this is really useful! Especially because none of this stuff is documented. I was wondering if you know of anymore resources on this topic, or if you've written a tutorial on this?

Also do I need to make my own FPreveiwScene to have a world and manage actors within a scene? I would like to be able to change lighting/weather settings within the scene and I'm not really sure what I need setup to be able to do that.

Thanks again!

avatar image LDOGLONDON Jun 28 '19 at 03:53 AM

So I was able to get the viewport up, but right now its just copying the main level viewport. And I'm unable to move between levels because my viewport still has a reference to the map/level. So I have a couple questions, hopefully you'll be able to help me.

SEditorViewport::Construct isn't virtual and things like SSCSEditorViewport still uses it, so I'm not really sure how to implement the FPreviewScene. Could you elaborate on how that is implemented? What exactly do I need to hook up to my FPreviewScene? Also I'm not really sure what it is, the documentation is pretty vague. Could you elaborate on that? And I'm not seeing where I can give the scene actors or objects. Do you know where I can feed that stuff into the viewport?

Sorry for all these questions, but you seem like you have a lot of knowledge on the topic. And I need to take help wherever I can get it :P

Again thanks a lot for your insight!

(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