Skip to content

4.26 compatible version of ToolExample #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 82 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
45aa1d3
Compatibility - future version of UE4 requires explicit PCHHeaderFile…
ScottKirvan Feb 7, 2021
1a3e12c
Compatibility - future versions require use of the ImportSubsystem
ScottKirvan Feb 7, 2021
691d43a
Create README.md
ScottKirvan Feb 7, 2021
52eafa2
branch explanations section
ScottKirvan Feb 7, 2021
2ac7990
.
ScottKirvan Feb 7, 2021
5e837ac
.
ScottKirvan Feb 7, 2021
3ce8c82
update project file to 4.24
ScottKirvan Feb 7, 2021
1354cc6
adding .gitignore - making life easier
ScottKirvan Feb 7, 2021
63eb093
GameDir() to ProjectDir() - 4.24 depricated API name
ScottKirvan Feb 7, 2021
bba12ab
virtual destructor warning - implemented the virtual destructor, whic…
ScottKirvan Feb 7, 2021
1d7bb2e
4.24 IWYU compatibility - wip
ScottKirvan Feb 7, 2021
b5eee74
IWYU compatibility - wip
ScottKirvan Feb 7, 2021
9ad193e
updated depricated method FString::Trim() to FString::TrimStart
ScottKirvan Feb 7, 2021
5c99c46
IWYU - updated from legacy include paths
ScottKirvan Feb 7, 2021
1c4d6c5
Removing the local PCH revealed an undefined EDMode object
ScottKirvan Feb 7, 2021
6e456bf
fully updated to BuildSettingsVersion V2
ScottKirvan Feb 7, 2021
fa5f52a
4.24 update
ScottKirvan Feb 7, 2021
3ec279a
Merge pull request #1 from ScottKirvan/4.24
ScottKirvan Feb 7, 2021
d57758c
Project update to 4.25
ScottKirvan Feb 7, 2021
f9dad04
Added Visual Studio Code files to .gitignore
ScottKirvan Feb 7, 2021
a177560
Merge branch 'master' of https://github.com/ScottKirvan/ToolExample
ScottKirvan Feb 7, 2021
5b62ba1
4.25 notes
ScottKirvan Feb 7, 2021
355da4c
Merge pull request #2 from ScottKirvan/4.25
ScottKirvan Feb 7, 2021
0faac0f
typo
ScottKirvan Feb 7, 2021
ca4527c
Merge pull request #3 from ScottKirvan/4.24
ScottKirvan Feb 7, 2021
5a9f123
added .ignore
ScottKirvan Feb 7, 2021
36f5481
4.26 update
ScottKirvan Feb 7, 2021
700bdb1
Merge pull request #5 from ScottKirvan/4.26
ScottKirvan Feb 8, 2021
c659974
Update README.md
ScottKirvan Feb 8, 2021
de756e1
Update README.md
ScottKirvan Feb 8, 2021
8d2e981
formatting
ScottKirvan Feb 8, 2021
d2bc316
DefaultEditorSettins.ini - created in tutorial
ScottKirvan Feb 8, 2021
a64d2cd
Update README.md
ScottKirvan Feb 9, 2021
b574e44
Update README.md
ScottKirvan Feb 9, 2021
a493b7e
Update README.md
ScottKirvan Feb 9, 2021
7a04b26
Update README.md
ScottKirvan Feb 9, 2021
5f676d4
Update README.md
ScottKirvan Feb 9, 2021
6d9bcc5
updated readme with some details about what's covered in the example
ScottKirvan Mar 10, 2021
e9ff013
added .idea ignore - jetbrains
ScottKirvan Mar 10, 2021
b5dd031
adding a backup of the original documentation/article to the repository
ScottKirvan Mar 10, 2021
1809e55
moving the documentation folder to the root of the repo
ScottKirvan Mar 10, 2021
36ba7f1
added .idea folder to .gitignore (jetbrains?)
ScottKirvan Mar 25, 2021
51caabc
Merge branch 'master' of https://github.com/ScottKirvan/ToolExample
ScottKirvan Mar 25, 2021
3228c99
renamed the docs folder
ScottKirvan Mar 25, 2021
71f9021
Create index.html
ScottKirvan Mar 25, 2021
3aeb35c
ignore new files added to the project by 5.1
ScottKirvan Mar 19, 2023
47010ed
bump supported uproject version to 5.1
ScottKirvan Mar 19, 2023
36ec8fe
UE5.1 added an android section - probably unnecessary
ScottKirvan Mar 19, 2023
8fa4666
always require the latest include order
ScottKirvan Mar 19, 2023
6c97657
adds EditorFramework to the linker
ScottKirvan Mar 19, 2023
357f2f4
replaces FEditorStyle with FAppStyle (UE5.1 compat)
ScottKirvan Mar 19, 2023
a4dfa09
update readme to 5.1 version
ScottKirvan Mar 19, 2023
526a981
ignore .obsidian folder
ScottKirvan Mar 19, 2023
e7ce8a4
Merge pull request #7 from ScottKirvan/master
ScottKirvan Mar 19, 2023
1b8d3e3
Merge pull request #8 from ScottKirvan/5.1
ScottKirvan Mar 19, 2023
8ca94ec
Update LICENSE
ScottKirvan Mar 19, 2023
39bf658
properly credit and rename the MIT license file
ScottKirvan Mar 19, 2023
9700b6f
WIP - fleshes out the readme a bit more
ScottKirvan Mar 19, 2023
98dbfcc
Revert "properly credit and rename the MIT license file"
ScottKirvan Mar 19, 2023
b5823d8
Merge pull request #10 from ScottKirvan/5.1
ScottKirvan Mar 19, 2023
51f1348
Merge pull request #11 from ScottKirvan/master
ScottKirvan Mar 19, 2023
8c3fcc2
Rename LICENSE file for Obsidian
ScottKirvan Mar 19, 2023
8185fe0
Merge pull request #12 from ScottKirvan/5.1
ScottKirvan Mar 19, 2023
0af755b
fix markdown whitespace
ScottKirvan Mar 19, 2023
b259a5e
Merge pull request #13 from ScottKirvan/5.1
ScottKirvan Mar 19, 2023
10dc9d9
flesh out sys reqs, support, etc.
ScottKirvan Mar 19, 2023
bb821e9
fix sys reqs link, fix email link
ScottKirvan Mar 19, 2023
e84aaaf
add a splash image and clarify the compiler usage
Mar 20, 2023
cc8bdfe
Update README.md
ScottKirvan Mar 20, 2023
a98aa79
Merge pull request #14 from ScottKirvan/5.1
ScottKirvan Mar 20, 2023
598ee87
update to UE 5.2 Preview 1 (experimental)
Mar 26, 2023
84ef8b9
Update LICENSE.md
ScottKirvan May 5, 2023
e06b974
Address asset issue
Razdvizh Aug 11, 2023
3320105
Delete MyData.uasset
Razdvizh Aug 11, 2023
bbd82eb
Merge pull request #15 from Razdvizh/master
ScottKirvan Aug 17, 2023
a71c391
Update README.md
ScottKirvan Aug 17, 2023
2eba3c5
Update README.md
ScottKirvan Aug 30, 2023
016af6a
Update README.md
ScottKirvan Aug 30, 2023
e4ce153
Fix: Compiler error because of `UExampleDataFactory::MakeExampleDataF…
duyaokun Dec 15, 2024
85af56a
Update README.md
ScottKirvan Dec 15, 2024
85b0537
Update README.md - credits :-)
ScottKirvan Dec 15, 2024
d183639
fix: compilation for 5.5 by updating build settings (#17)
BryanBrouwer Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.ignore
ToolExample.sln
ToolExample.code-workspace
.vs/
.vscode/
.idea/
Binaries/
Intermediate/
Saved/
.idea/

Config/DefaultEditorUserSettings.ini
.vsconfig
Config/DefaultInput.ini
.obsidian/
14 changes: 14 additions & 0 deletions Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[URL]

[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=
GameDefaultMap=
Expand Down Expand Up @@ -51,4 +52,17 @@ AsyncSceneSmoothingFactor=0.990000
InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10

[/Script/AndroidFileServerEditor.AndroidFileServerRuntimeSettings]
bEnablePlugin=True
bAllowNetworkConnection=True
SecurityToken=6607BEA0438D48653A04889817D4749C
bIncludeInShipping=False
bAllowExternalStartInShipping=False
bCompileAFSProject=False
bUseCompression=False
bLogFiles=False
bReportStats=False
ConnectionType=USBOnly
bUseManualIPAddress=False
ManualIPAddress=

3 changes: 2 additions & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2019 Eric Zhang
Copyright (c) 2019 Eric Zhang
This code includes modifications by Scott Kirvan. Modifications (c) Scott Kirvan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
107 changes: 107 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# [ScottKirvan/ToolExample](https://github.com/ScottKirvan/ToolExample)
ToolExample contains UX/UI C/C++ examples for adding tools and UI elements to the [Unreal Engine](https://www.unrealengine.com) editor - which means, these are editor tools for the artist, and not an example of how to write the runtime game code that a player would interact with.

![Splash Image](docs/images/splash.png)

If you're looking for an example to show how to add an item to the existing menu, or a new edit mode, or how to create a dockable window, this is a really thorough, [step-by-step example](https://lxjk.github.io/2019/10/01/How-to-Make-Tools-in-U-E.html) that starts from an empty code project, immediately jumps into the base modules needed, and then clearly walks through the steps to code up various UI elements, hooking them to functionality as you go.

# Features
These examples demonstrate how to implement the following:
- adding modules
- adding menus to the editor interface with:
- sections
- menu items
- sub menus
- adding custom widgets and controls (button and text input) to the menu
- adding a dockable tab Window
- custom details panel
- defining and adding your own custom asset data type (data factory)
- importing/reimporting custom data
- custom editor mode
- custom editor viewport widget
- viewport object context sensitive right-click & menus
- custom project settings/preferences
- additional tricks and tips

This repo is an updated fork of [Eric Zhang's](https://github.com/lxjk) original [UE4 project](https://github.com/lxjk/ToolExample). The excellent step-by-step documentation can be found here: [How to Make Tools in UE4](https://lxjk.github.io/2019/10/01/How-to-Make-Tools-in-U-E.html) I've included a stripped down version of that tutorial in this repo in case anything happens to that URL in the future.

This tutorial has become the most valuable one I've run across in my Unreal C++ journey. It got me started in an area of programming in Unreal that I found pretty impenetrable at first, and it has continued to be a reference point that I return to frequently whenever I'm thinking I want some new functionality (or just some easier-to-get-at functionality) inside Unreal. My deepest gratitude to Eric for his contribution here.

## Branches
- master
- current development branch - this will likely have the most recent code - note: this branch does work with UE 5.2 Preview 1
- 5.1
- UE 5.1 Compatible
- There was some header changes, a new module dependency, and class FEditorStyle was deprecated and replaced with FAppStyle.
- I tested this very briefly, but it all looks good!
- 4.26
- UE 4.26 Compatible.
- Example Editor Mode is working in this version, so I'm not going to bother trying to figure out what broke in 4.25. If anyone takes this on as a project, please toss up a Pull Request.
- initial branch source is identical to 4.24/4.25
- 4.25
- UE 4.25 Compatible.
- builds and runs, but the Example Editor Mode isn't working. It shows up in the Modes list, but the UI never gets built when selected. I didn't see any errors or warnings anywhere.
- NOTE: The editor mode issue works in 4.26 without any code changes.
- as it stands, this source is identical to the 4.24 branch
- 4.24
- UE 4.24 Compatible.
- updates build.cs to V2 target.
- implements [IWYU](https://docs.unrealengine.com/en-US/ProductionPipelines/BuildTools/UnrealBuildTool/IWYU/index.html) standard.
- 4.23
- original fork from [lxjk/ToolExample](https://github.com/lxjk/ToolExample).
- UE 4.23 compatible.

## Contributing
Do you know how to create a UI tool that would be good to include in this example? Interested in contributing with writing or anything else? Did you find a bug?! Please help out! Check the issues link to see the kinds of things that might be fun to tackle.

The best way to contribute would be with [Pull Requests (PR)](https://github.com/ScottKirvan/ToolExample/pulls): Fork this repository, make your changes, and submit a New Pull Request that can be reviewed and rolled back in.

If you don't want to do the Write/PR process yourself, but would still like to contribute, just use the [Issues](https://github.com/ScottKirvan/ToolExample/issues) link above to report bugs or request something new you'd like to see.

## System Requirements
- Computer capable of Unreal Engine development
- Epic Recommends [this.](https://docs.unrealengine.com/5.1/en-US/hardware-and-software-specifications-for-unreal-engine/)
- The typical system used by developers at Epic Games looks like this:
- Windows 10 64-bit (Version 20H2)
- 64 GB RAM
- 256 GB SSD (OS Drive)
- 2 TB SSD (Data Drive)
- NVIDIA GeForce RTX 2080 SUPER
- Xoreax Incredibuild (Dev Tools Package)
- Six-Core Xeon E5-2643 @ 3.4GHz
- I get by with a 16 core AMD Ryzen 9, Windows 11, MSDev2022, and 40 GB RAM on my gaming laptop.
- Unreal Engine 5.5
- This repo also supports older versions, just download/clone the [branch](https://github.com/ScottKirvan/ToolExample/branches) you need.
- Microsoft Visual Studio 2022
- Epic still recommends the 2019 version, but I'm using 2022 - get the free-to-use [Community version here](https://visualstudio.microsoft.com/vs/community/).
- This repo supports older versions, just clone the branch you need.
- Microsoft Visual Studio 2019
- the 2022 version works as well, but you have to explicitly tell unreal engine to use 2022 (`Edit -> Editor Preferences... -> Source Code -> Source Code Editor`).

## Getting Started With Local Development
Clone or download this repo. If you have Unreal and Visual Studio properly installed, double clicking the `uproject` file should launch Unreal, which will recognize it as a code project and build everything automatically.

I highly recommend following the Tutorial and using this code as reference. If you hit an error, look at this code to see what may have changed.

A couple of other good resources for getting started:
- [Setting Up Visual Studio for EU5.1](https://docs.unrealengine.com/5.1/en-US/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine/)
- [UE5.1 Programming Quickstart](https://docs.unrealengine.com/5.1/en-US/unreal-engine-cpp-quick-start/)

## Support/Contact
- Feel free to reach out to me on the [Unreal Slackers](https://discord.gg/unreal-slackers) discord. I'm @Fragmanget_. There is also a ton of other Unreal programmers up there, so if I'm not around to help, someone else be able to get you going.
- You can also reach me on my personal [Discord Server](https://discord.gg/TSKHvVFYxB) (@cptvideo), via [LinkedIn](https://www.linkedin.com/in/scottkirvan/), or <a href="mailto:[email protected]">email</a>.

## Submit a Feature Request
Use the [Issues](https://github.com/ScottKirvan/ToolExample/issues) link, above. Thanks!

## Credits
A huge thank you to [Eric Zhang](https://github.com/lxjk) for the work he put into the [original tutorial project](https://lxjk.github.io/2019/10/01/How-to-Make-Tools-in-U-E.html).

Contributors:
[Eric Zhang](https://github.com/lxjk) (OG!)
[Scott Kirvan](https://github.com/ScottKirvan) (2021-present)
[Razdvizh](https://github.com/Razdvizh) (2023)
[duyaokun](https://github.com/duyaokun) (2024)
You! (Future!)

_ToolExample is licensed under the [MIT License](LICENSE.md)._
4 changes: 3 additions & 1 deletion Source/ToolExampleEditor.Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ public class ToolExampleEditorTarget : TargetRules
public ToolExampleEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V5;
IncludeOrderVersion = EngineIncludeOrderVersion.Latest;

ExtraModuleNames.AddRange( new string[] { "ToolExample" } );
ExtraModuleNames.AddRange( new string[] { "ToolExample" } );
ExtraModuleNames.AddRange( new string[] { "ToolExampleEditor" });
}
}
41 changes: 4 additions & 37 deletions Source/ToolExampleEditor/CustomDataType/ExampleDataFactory.cpp
Original file line number Diff line number Diff line change
@@ -1,49 +1,16 @@
#include "ToolExampleEditor/ToolExampleEditor.h"
#include "ExampleDataFactory.h"
#include "CustomDataType/ExampleData.h"
#include "ToolExampleEditor/ToolExampleEditor.h"
#include "ToolExample/CustomDataType/ExampleData.h"

UExampleDataFactory::UExampleDataFactory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
Formats.Add(TEXT("xmp;Example Data"));
SupportedClass = UExampleData::StaticClass();
bCreateNew = false; // turned off for import
bEditAfterNew = false; // turned off for import
bEditorImport = true;
bText = true;
bCreateNew = true;
bEditAfterNew = true;
}

UObject* UExampleDataFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
{
UExampleData* NewObjectAsset = NewObject<UExampleData>(InParent, Class, Name, Flags | RF_Transactional);
return NewObjectAsset;
}

UObject* UExampleDataFactory::FactoryCreateText(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, const TCHAR* Type, const TCHAR*& Buffer, const TCHAR* BufferEnd, FFeedbackContext* Warn)
{
FEditorDelegates::OnAssetPreImport.Broadcast(this, InClass, InParent, InName, Type);

// if class type or extension doesn't match, return
if (InClass != UExampleData::StaticClass() ||
FCString::Stricmp(Type, TEXT("xmp")) != 0)
return nullptr;

UExampleData* Data = CastChecked<UExampleData>(NewObject<UExampleData>(InParent, InName, Flags));
MakeExampleDataFromText(Data, Buffer, BufferEnd);

// save the source file path
Data->SourceFilePath = UAssetImportData::SanitizeImportFilename(CurrentFilename, Data->GetOutermost());

FEditorDelegates::OnAssetPostImport.Broadcast(this, Data);

return Data;
}

bool UExampleDataFactory::FactoryCanImport(const FString& Filename)
{
return FPaths::GetExtension(Filename).Equals(TEXT("xmp"));
}

void UExampleDataFactory::MakeExampleDataFromText(class UExampleData* Data, const TCHAR*& Buffer, const TCHAR* BufferEnd)
{
Data->ExampleString = Buffer;
}
6 changes: 1 addition & 5 deletions Source/ToolExampleEditor/CustomDataType/ExampleDataFactory.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#include "UnrealEd.h"
#include "ExampleDataFactory.generated.h"

Expand All @@ -9,10 +10,5 @@ class UExampleDataFactory : public UFactory
public:
// Begin UFactory Interface
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
virtual UObject* FactoryCreateText(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, const TCHAR* Type, const TCHAR*& Buffer, const TCHAR* BufferEnd, FFeedbackContext* Warn) override;
virtual bool FactoryCanImport(const FString& Filename) override;
// End UFactory Interface

// helper function
static void MakeExampleDataFromText(class UExampleData* Data, const TCHAR*& Buffer, const TCHAR* BufferEnd);
};
17 changes: 3 additions & 14 deletions Source/ToolExampleEditor/CustomDataType/ExampleDataTypeActions.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ToolExampleEditor/ToolExampleEditor.h"
#include "ExampleDataTypeActions.h"
#include "CustomDataType/ExampleData.h"
#include "ToolExampleEditor/ToolExampleEditor.h"
#include "ToolExample/CustomDataType/ExampleData.h"
#include "XMPAssetTypeActions_Base.h"


FExampleDataTypeActions::FExampleDataTypeActions(EAssetTypeCategories::Type InAssetCategory)
Expand Down Expand Up @@ -42,15 +43,3 @@ void FExampleDataTypeActions::GetActions(const TArray<UObject*>& InObjects, FMen
)
);
}

void FExampleDataTypeActions::ExecuteReimport(TArray<TWeakObjectPtr<UExampleData>> Objects)
{
for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)
{
auto Object = (*ObjIt).Get();
if (Object)
{
FReimportManager::Instance()->Reimport(Object, /*bAskForNewFileIfMissing=*/true);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "AssetTypeActions_Base.h"
#include "XMPAssetTypeActions_Base.h"

class UExampleData;

class FExampleDataTypeActions : public FAssetTypeActions_Base
class FExampleDataTypeActions : public FXMPAssetTypeActions_Base
{
public:
FExampleDataTypeActions(EAssetTypeCategories::Type InAssetCategory);
Expand All @@ -18,8 +18,6 @@ class FExampleDataTypeActions : public FAssetTypeActions_Base
virtual void GetActions(const TArray<UObject*>& InObjects, FMenuBuilder& MenuBuilder) override;
// End of IAssetTypeActions interface

void ExecuteReimport(TArray<TWeakObjectPtr<UExampleData>> Objects);

private:
EAssetTypeCategories::Type MyAssetCategory;
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ToolExampleEditor/ToolExampleEditor.h"
#include "ReimportExampleDataFactory.h"
#include "ToolExampleEditor/ToolExampleEditor.h"
#include "ExampleDataFactory.h"
#include "CustomDataType/ExampleData.h"
#include "ToolExample/CustomDataType/ExampleData.h"

bool UReimportExampleDataFactory::CanReimport(UObject* Obj, TArray<FString>& OutFilenames)
{
Expand Down Expand Up @@ -44,9 +44,7 @@ EReimportResult::Type UReimportExampleDataFactory::Reimport(UObject* Obj)
const TCHAR* Ptr = *Data;
ExampleData->Modify();
ExampleData->MarkPackageDirty();

UExampleDataFactory::MakeExampleDataFromText(ExampleData, Ptr, Ptr + Data.Len());

ExampleData->ExampleString = Ptr;
// save the source file path and timestamp
ExampleData->SourceFilePath = UAssetImportData::SanitizeImportFilename(CurrentFilename, ExampleData->GetOutermost());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "XMPAssetTypeActions_Base.h"
#include "ToolExample/CustomDataType/ExampleData.h"
#include "EditorReimportHandler.h"
#include "EditorFramework/AssetImportData.h"
#include "Misc/FileHelper.h"

bool FXMPAssetTypeActions_Base::CanReimport(UObject* Obj, TArray<FString>& OutFilenames)
{
UExampleData* ExampleData = Cast<UExampleData>(Obj);
if (ExampleData)
{
OutFilenames.Add(UAssetImportData::ResolveImportFilename(ExampleData->SourceFilePath, ExampleData->GetOutermost()));
return true;
}
return false;
}

void FXMPAssetTypeActions_Base::SetReimportPaths(UObject* Obj, const TArray<FString>& NewReimportPaths)
{
check(NewReimportPaths.IsValidIndex(0));
if (UExampleData* ExampleData = Cast<UExampleData>(Obj))
{
ExampleData->SourceFilePath = UAssetImportData::SanitizeImportFilename(NewReimportPaths[0], ExampleData->GetOutermost());
}
}

EReimportResult::Type FXMPAssetTypeActions_Base::Reimport(UObject* Obj)
{
UExampleData* ExampleData = Cast<UExampleData>(Obj);
if (!ExampleData)
{
return EReimportResult::Failed;
}

const FString Filename = UAssetImportData::ResolveImportFilename(ExampleData->SourceFilePath, ExampleData->GetOutermost());

FString Data;
if (FFileHelper::LoadFileToString(Data, *Filename))
{
const TCHAR* Ptr = *Data;
ExampleData->Modify();
ExampleData->MarkPackageDirty();

ExampleData->ExampleString = Ptr;
ExampleData->SourceFilePath = UAssetImportData::SanitizeImportFilename(Filename, ExampleData->GetOutermost());
}

return EReimportResult::Succeeded;
}

void FXMPAssetTypeActions_Base::ExecuteReimport(TArray<TWeakObjectPtr<UExampleData>> Objects)
{
for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)
{
auto Object = (*ObjIt).Get();
if (Object)
{
Reimport(Object);
}
}
}
Loading