vault backup: 2024-10-12 17:19:45

This commit is contained in:
2024-10-12 17:19:46 +08:00
parent ff94ddca61
commit 244c0c52f6
960 changed files with 31348 additions and 10 deletions

View File

@@ -0,0 +1,70 @@
# EditorConfig
- **功能描述:** 用来在编辑器状态下保存信息。
- **引擎模块:** Config, Editor
- **元数据类型:** string="abc"
- **作用机制:** 在Meta中增加[EditorConfig](../../../../Meta/Config/EditorConfig.md)
- **常用程度:★**
用来在编辑器状态下保存信息。
一般用在EditorTarget的Module里用于配置相应编辑器的信息比如列宽收藏夹之类的用json保存。
保存在C:\Users\{user name}\AppData\Local\UnrealEngine\Editor。当前有
![Untitled](Untitled.png)
在源码里搜索后,使用的时候必须继承于基类:
```cpp
/** Inherit from this class to simplify saving and loading properties from editor configs. */
UCLASS()
class EDITORCONFIG_API UEditorConfigBase : public UObject
{
GENERATED_BODY()
public:
/** Load any properties of this class into properties marked with metadata tag "EditorConfig" from the class's EditorConfig */
bool LoadEditorConfig();
/** Save any properties of this class in properties marked with metadata tag "EditorConfig" into the class's EditorConfig. */
bool SaveEditorConfig() const;
};
```
## 示例代码:
```cpp
UCLASS(EditorConfig = "MyEditorGame")
class INSIDER_API UMyClass_EditorConfig : public UEditorConfigBase
{
public:
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (EditorConfig))
int32 MyPropertyWithConfig = 123;
};
void UMyClass_EditorConfig_Test::TestConfigSave()
{
//must run after editor initialization
auto* testObject = NewObject<UMyClass_EditorConfig>(GetTransientPackage(), TEXT("testObject_EditorConfig"));
testObject->MyPropertyWithConfig = 777;
testObject->SaveEditorConfig();
}
void UMyClass_EditorConfig_Test::TestConfigLoad()
{
auto* testObject = NewObject<UMyClass_EditorConfig>(GetTransientPackage(), TEXT("testObject_EditorConfig"));
testObject->LoadEditorConfig();
}
//运行Save后的保存结果C:\Users\jack.fu\AppData\Local\UnrealEngine\Editor\MyEditorGame.json
{
"$type": "MyClass_EditorConfig",
"MyPropertyWithConfig": 777
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB