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.
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)
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
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)
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.
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