Custom File Type
Files in the simulator are UObject classes based on UOperatingSystemFile. When the player double-clicks a file in Explorer, the OS spawns the file’s widget and/or launches the Target Program Class.
Bundled examples:
| Class | Extension | Opens with |
|---|---|---|
| UOperatingSystemVideoFile | .mp4, etc. | Video Player |
| UOperatingSystemAudioFile | .mp3, etc. | Audio Player |
flowchart TB
subgraph row1[" "]
direction LR
File["UOperatingSystemFile subclass"] --> Ext["Extension + IconObject"] --> Prog["TargetProgramClass"]
end
subgraph row2[" "]
direction LR
Explorer["UOperatingSystemExplorer double-click"] --> Open["On Open → launch UOperatingSystemBaseProgram"]
end
Explorer --> File
File --> Open
Blueprint file type
Section titled “Blueprint file type”1. Create the file class
Section titled “1. Create the file class”- Content Browser → Blueprint Class → Operating System File
- Name it
BP_File_MyDoc - Set properties:
| Property | Example |
|---|---|
| Name | My Document (display; instance name set at runtime) |
| Extension | .mydoc |
| Icon Object | Your texture or UI material |
| Target Program Class | Your program Blueprint |
| Icon Widget Class | WBP_FileIcon (duplicate from plugin) |
| Widget Class | Optional preview widget |
2. Create file instances at runtime
Section titled “2. Create file instances at runtime”Use Construct File on your program or OS static helpers from UOperatingSystemStatics to place files in a directory.
Blueprint pattern:
Get Operating System → Get Directory by Path → Construct File (Class: BP_File_MyDoc, Parent Directory: …)3. Handle open
Section titled “3. Handle open”Override On Open on the file Blueprint to run custom logic before the target program launches.
C++ file type
Section titled “C++ file type”UCLASS()class UMyDocumentFile : public UOperatingSystemFile{ GENERATED_BODY()
public: UMyDocumentFile() { Extension = FText::FromString(TEXT(".mydoc")); }
protected: virtual void OnOpen() override;};Register Target Program Class in defaults to your UMyDocumentProgram class.
File + program pairing
Section titled “File + program pairing”For programs that create files (like Mail or Video Player), also define:
- A Data Class on the program (UOperatingSystemProgramData)
- File construction in the program’s install or save logic
See Video Player file and Audio Player file for full examples.