Skip to content

Commit 5125f93

Browse files
committed
WIP custom overlay for prefs serialization
1 parent 28c42a0 commit 5125f93

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using UnityEditor;
5+
6+
namespace Toolbox.Editor
7+
{
8+
internal static class ToolboxPrefs
9+
{
10+
private const string separator = ".";
11+
private const string keyBase = "Toolbox";
12+
13+
private static readonly HashSet<string> usedKeys = new HashSet<string>();
14+
15+
16+
private static string GetKey(object causer, string propertyName)
17+
{
18+
return GetKey(causer.GetType(), propertyName);
19+
}
20+
21+
private static string GetKey(Type causer, string propertyName)
22+
{
23+
return GetKey(causer.Name, propertyName);
24+
}
25+
26+
private static string GetKey(string causer, string propertyName)
27+
{
28+
return string.Format("{0}{3}{1}{3}{2}", keyBase, causer, propertyName, separator);
29+
}
30+
31+
32+
public static void DeleteAll()
33+
{
34+
EditorPrefs.DeleteAll();
35+
}
36+
37+
public static void DeleteCached()
38+
{
39+
//TODO:
40+
}
41+
42+
public static bool GetBool(string causer, string propertyName, bool defaultValue)
43+
{
44+
var key = GetKey(causer, propertyName);
45+
return EditorPrefs.GetBool(key, defaultValue);
46+
}
47+
48+
public static T GetValue<T>(string causer, string propertyName, T defaultValue)
49+
{
50+
return default;
51+
}
52+
}
53+
}

Assets/Editor Toolbox/Editor/ToolboxPrefs.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)