forked from XINCGer/UnityToolchainsTrick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample_12_PerferenceExtension.cs
78 lines (71 loc) · 2.81 KB
/
Example_12_PerferenceExtension.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace ToolKits
{
public class Example_12_PerferenceExtension
{
private static bool loaded = false;
private static string context = "";
private static bool sceneviewSwitch;
private static bool duplicateEventListen = false;
private const string KEY = "__ToolChainsTrick_Context__";
private static bool globalInputEventEnable = false;
#if UNITY_2019_1_OR_NEWER
[SettingsProvider]
private static SettingsProvider ToolChainsTrickSetting()
{
var provider = new SettingsProvider("Preferences/ToolChainsTrick", SettingsScope.User)
{
guiHandler = (string key) => { PreferenceGUI(); },
keywords = new string[] {"Tool", "Chains", "Trick"},
};
return provider;
}
#else
[PreferenceItem( "ToolChainsTrick" )]
#endif
private static void PreferenceGUI()
{
if (!loaded)
{
Load();
}
EditorGUI.BeginChangeCheck();
context = EditorGUILayout.TextField(new GUIContent("文本配置"), context);
if (EditorGUI.EndChangeCheck())
{
EditorPrefs.SetString(KEY, context);
}
EditorGUI.BeginChangeCheck();
sceneviewSwitch = EditorGUILayout.Toggle("SceneView拓展开关", sceneviewSwitch);
if (EditorGUI.EndChangeCheck())
{
EditorPrefs.SetBool(Constants.SCENE_VIEW_EXTENSITON_SWITH, sceneviewSwitch);
SceneViewExtension.EditorInitialize();
}
EditorGUI.BeginChangeCheck();
globalInputEventEnable = EditorGUILayout.Toggle("是否开启全局检测事件", globalInputEventEnable);
if (EditorGUI.EndChangeCheck())
{
EditorPrefs.SetBool(Constants.GLOBAL_INPUT_ENEVT_ENABLE,globalInputEventEnable);
GlobalInputEvent.EditorInitialize();
}
EditorGUI.BeginChangeCheck();
duplicateEventListen = EditorGUILayout.Toggle("是否监听Hierarchy的Ctrl+D事件", duplicateEventListen);
if (EditorGUI.EndChangeCheck())
{
EditorPrefs.SetBool(Constants.DuplicateEventListen,duplicateEventListen);
Example_71_UnityDuplicateEvent.EditorInitialize();
}
}
private static void Load()
{
context = EditorPrefs.GetString(KEY, "");
sceneviewSwitch = EditorPrefs.GetBool(Constants.SCENE_VIEW_EXTENSITON_SWITH, false);
loaded = true;
duplicateEventListen = EditorPrefs.GetBool(Constants.DuplicateEventListen, false);
}
}
}