I’m creating a BP library as a plugin. I have a function in the lib class that would need to work differently when InEditor.
The problem of course is that the Runtime library can’t link to UnrealEd, and, preferably, I’d like to use the same “node” in my Blueprints with the same function name.
Specifically, the function has to do with Viewports. When Simulating inEditor, the viewport is not the player’s one, it’s the EditorViewport… so whatever my Runtime function does with the viewport, will only work only if PIE, and not when Simulating.
Out of curiosity, and to fill the gaps due to a poor description here, what function are you making that should do identical work both in editor and in game?
It would also be good if you described your problem in more detail. This way we can see if there is a design flaw in your thinking/programming. There is a reason as to why Epic has editor modules and runtime modules. Usually you should not need to mix these two together.
The function gets the current LOD level rendered for a StaticMeshComponent. Since the variable previousLODLevel, held by the class has been reported - and I was able to verify - to be bugged as it is always zero at all times.
I was able to make it work using the Runtime layer when PIE, but with Simulate the view is not that of the Pawn… it’s the Editor viewport… so it won’t work in that case.
Anyway, I managed it all. Implemented both for Pawn view and Editor Viewport.