I placed a SceneCapture2D actor into my scene using “drag and drop”. Now I want to modify customize its c++ code… I need several different instance of it. Despite clicking on “Refresh VS project” I cannot find the .h and .cpp files beonging to this specific instance of SceneCapture2D.
Q: How can I edit / customize C++ code of actors placed into the scene via the editor ?
PS: “Adding new c++ class” is also not working, since SceneCapture2D cannot be choosen from the list offered.
Thanks for any hep
Add a new C++ class, derive from any actor class type. In Visual Studio, go to the header of your new actor and change the actor class type you chose to derive from to ASceneCapture2D.
So, let’s say you chose to derive from Actor and your type is CustomSceneCapture2D. You’ll currently see this in the header that was generated by the editor:
class ACustomSceneCapture2D : public AActor
Change it to be:
class ACustomSceneCapture2D : public ASceneCapture2D
Aha! I just took a look at the code for ASceneCapture2D and it looks like it’s declaring MinimalAPI - so it doesn’t look like you can derive from it.
I thought I had another good suggestion for you in that you could replace the NewSceneCaptureComponent2D property with your own component - but you can’t derive from USceneCaptureComponent2D either for the same reason.
So maybe a better question would be… what are you trying to achieve?
Thanks for your answer ! I’ve already tried this before posting the question, but unfortunately if I do this I get the following error message:when trying to build:
Error 1 error C2512: ‘ASceneCapture2D’ : no appropriate default constructor available C:\Users\John\Documents\Unreal Projects\MyProject2\Source\MyProject2\MyCapture.cpp 9 1 MyProject2
I had a couple real quick questions for you. First, are you using the binary version of the Engine installed by the Launcher, or did you build the Engine from source code? Second, what do you mean when you say that SceneCapture2D cannot be selected when adding a new code class? Did you click the Show All Classes checkbox? You should be able to find SceneCapture2D there and select it as the parent of your new class. Do you not see this as an option?
Thanks, a lot, indeed maybe it is better to sketch my goal which is the following. I need a tool attached to (moving together with ) another Actor that I can use to get (access) the image memory (render target) from its point of view and process/copy/save the image further. So think for example a “gopro” camera attached to the head of a cyclist. I want to process the image of that camera in every ::Tick. I thought tha SceneCapture2D is a good tool for this, but maybe a Camera(Component) can also do this job.
Thanks a lot again,
Thanks for the help… my bad. Indeed with the image provided I was able to find SceneCapture2D in the hierarchy sorry for that. I’m using UE4 4.7.5 pre-built binary version.
Thanks a lot and sorry for not digging deep enough !
G
But staying with the original question, what about actors that are placed by drag and drop not via “Add new c++ code” option ? Is there a was to edit their codes ?
I am guessing that you are referring to using the Modes panel or Class Viewer to select a class and drag it into your level, correct (both of these would provide the same end result)?
The answer to your question in that case would depend on whether you are using the binary version of the Engine installed through the Launcher or if you built the Engine yourself from source code.
The classes that you can drag into a level from the Modes panel or Class Viewer are found in the source code. If you are using a binary version of the Engine, then you won’t be able to edit the code for these files (As of 4.7 you are able to look at the code). If you have built the Engine from source code, then you are able to modify any part of the source code, including these classes. However, that may not be a good idea since it could potentially lead to unintended consequences, especially if other classes reference the class you are modifying. Creating a new class that is derived from the original class would probably be the best option to customize the class.
If you have some instances of a class already placed in a level, and you want to modify the class, any modifications that you make to the class will be included in the instances that are already in the level. This does not matter if you are modifying the original class in source code, or if you are modifying a custom class that you have created. One thing to keep in mind, though, is that the modifications will be applied to all instances of that class. If you only want to modify one instance of that class, you would need to make a custom class for that instance, then replace the existing instance in the level with an instance of your new custom class.
The solution here would depend on what you intend to do with the images. If you will be only using them within your game, then the SceneCapture2D would probably be the better option. However, if you want to be able to take the images out of your game to do something with them externally, then you will probably want to use a Camera. This last option would most likely require a great deal of custom code to get it working, though.
Yes, I want to export the image to be used externally…,… the ultimate goal is that the UE projects compiles to a dll which can be used by external application which can get the camera image from the dll… that part is described here: