Runtime Content Saves & Data Reads
Alright, so this one's for the slate & programming teams.
Would the team consider implementing a way to read and write in capture data for slate / UI menus to use, without having to go through the content browser? Or, if failing that, would the devs consider allowing for SceneCaptures, Matinee Movie Dumps and/or tiledshots to be stored in the content browser at runtime for slate and native access?
I was looking through FileManager.h and FileHelpers.h based on an old discussion I had with Bob Tellez. There are some functions in there related to file handling, but there doesn't appear to be much you can really do with the list of functions currently available. You have your basic move/copy stuff and accessor functions for file handling. But there's nothing really in terms of reading or direct writing to files, or the serialization (and encryption!) of data as might be expected from BasicSaveObject/BasicLoadObject. If it's handled somewhere else and I'm just unaware, I'd appreciate some insight.
Anyways, I'll point to an example of how this might be used in practice. in my DataHive project, I wanted to enhance my current save system by getting a snapshot of the current save area and reading them into my Flash save menu*. I would give the saved thumbnails a specific naming convention to distinguish them from other files. In this way, the thumbnail system would be completely procedural. Unfortunately that proved to be unworkable b/c of how UE3's content packaging system was designed.
Now in terms of implementation, one way is to provide accessor functions for reading in files and doing the usual vetting to check for bad or invalid content. Treat it almost like a content browser import, except this would operate at the native level.
Or if direct reads are too risky, then perhaps allowing for a new and improved screencapture2D, matinee dump, or shot command to save its captures into the content browser at runtime.
The basic premise here would be that you could create a file that is vetted by native architecture, and thus is assured to be clean (or as clean as this architecture can make a file...). All that's left is a way for slate menus, blueprints, etc. to read in the newly generated capture files.
asked Mar 11 '14 at 02:10 AM in C++ Programming
ue4-archive ♦♦ STAFF
SceneCapture2Ds write their data to a UTextureRenderTarget2D (you create in the content browser) which can be used directly in slate by making a brush then using it like so:
Do this once at startup:
Now just use the brush like so:
Matinee movie dumps and tiledshots were not meant to be used progamatically as they just write their output to disk. If you want to write some logic to work with thier output, you may want to start by using one of the techniques below.
Now, since you asked, here is some more general info about saving/loading:
Once you have an FArchive, you can serialize primitive types or UObjects into it by using the << operator like so:
Loading with an FArchive is similar
As an alternative to dealing with data at this low level, you may want to use the package system. Here is saving.
Where MyCoolObject is a class containing all the data you care about. Now here is loading.
You will want to use the same UPackage returned from LoadPackage when calling UPackage::SavePackage.
Forgive me if there are any syntax errors in the code samples above, I just typed them out in this message.
Finally, you may want some more power over your saved objects. In this case you will want to make a custom asset type, then saving and loading is managed automatically for you. One of the easiest ways to do this is to make your data class extend UDataAsset. Then it can be created in the content browser and saved just like normal packages. If you want to get more involved in making an asset type, you can also make a UFactory class and IAssetTypeActions class to add extra content browser functionality. I do not see any doc pages about creating a new asset type, so I will ping the documentation team about adding one.
answered Mar 11 '14 at 02:10 AM
ue4-archive ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here