Skip to content

Commit

Permalink
feat: Add support for save settings in Library folder
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarianZ committed Oct 23, 2024
1 parent 9c2783d commit 761abbe
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
11 changes: 4 additions & 7 deletions Editor/EditorUserSettingsProjectStorage.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using UnityEditor;

namespace GBG.EditorUserSettings.Editor
namespace GBG.EditorUserSettings.Editor
{
[FilePath(RelativePath, FilePathAttribute.Location.ProjectFolder)]
internal class EditorUserSettingsProjectStorage : EditorUserSettingsStorage<EditorUserSettingsProjectStorage>
{
public EditorUserSettingsProjectStorage()
{
TypeName = typeof(EditorUserSettingsProjectStorage).Name;
}
#if GBG_EDITOR_USER_SETTINGS_USE_LIBRARY
public new const string RelativePath = "Library/" + EditorUserSettingsStorage<EditorUserSettingsProjectStorage>.RelativePath;
#endif
}
}
5 changes: 0 additions & 5 deletions Editor/EditorUserSettingsSharedStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ namespace GBG.EditorUserSettings.Editor
[FilePath(RelativePath, FilePathAttribute.Location.PreferencesFolder)]
internal class EditorUserSettingsSharedStorage : EditorUserSettingsStorage<EditorUserSettingsSharedStorage>
{
public EditorUserSettingsSharedStorage()
{
TypeName = typeof(EditorUserSettingsSharedStorage).Name;
}

protected override void Save(bool saveAsText)
{
base.Save(saveAsText);
Expand Down
4 changes: 0 additions & 4 deletions Editor/EditorUserSettingsStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ internal abstract class EditorUserSettingsStorage<TStorage> :
{
public const string RelativePath = "UserSettings/CustomEditorUserSettingsStorage.asset";

// For debug
[SerializeField]
protected string TypeName;

// For reference types and serializable value types
[SerializeField]
private StorageObject _storageObject = new StorageObject();
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ static class CustomEditorUserSettings
}
```

-`isSharedAcrossProjects``false` 时,数据只供当前项目使用。<br/>When `isSharedAcrossProjects` is `false`, the settings is only for the current project.
- 默认情况下,数据会保存在 `${Application.dataPath}/../UserSettings/CustomEditorUserSettingsStorage.asset` 中。<br/>By default settings will be saved in `${Application.dataPath}/../UserSettings/CustomEditorUserSettingsStorage.asset`.
- 如果项目中定义了 `GBG_EDITOR_USER_SETTINGS_USE_LIBRARY` 预编译指令,则数据会保存在 `${Application.dataPath}/../Library/UserSettings/CustomEditorUserSettingsStorage.asset` 中。<br/>If the `GBG_EDITOR_USER_SETTINGS_USE_LIBRARY` preprocessor directive is defined in the project, the settings will be saved in `${Application.dataPath}/../Library/UserSettings/CustomEditorUserSettingsStorage.asset`.
-`isSharedAcrossProjects``true` 时,数据可以跨项目共享,会保存在 `${InternalEditorUtility.unityPreferencesFolder}/UserSettings/CustomEditorUserSettingsStorage.asset` 中。<br/>When `isSharedAcrossProjects` is `true`, the settings can be shared across projects, and will be saved in `${InternalEditorUtility.unityPreferencesFolder}/UserSettings/CustomEditorUserSettingsStorage.asset`.


### 菜单项<br/>Menu Items

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.greenbamboogames.editorusersettings",
"version": "1.0.0",
"version": "1.0.1",
"displayName": "Editor User Settings!",
"description": "Store user settings in Unity Editor.",
"unity": "2019.4",
Expand Down

0 comments on commit 761abbe

Please sign in to comment.