A game about forced loneliness, made by TACStudios
1using System;
2using UnityEngine;
3
4namespace UnityEditor.U2D.Animation
5{
6 internal class SkinningModuleSettings
7 {
8 public const string kCompactToolbarKey = UserSettings.kSettingsUniqueKey + "AnimationEditorSetting.compactToolbar";
9 public const string kShowSpriteMeshOverwriteWarningKey = UserSettings.kSettingsUniqueKey + "AnimationEditorSetting.showSpriteMeshOverwriteWarning";
10 public static readonly GUIContent kCompactToolbarLabel = EditorGUIUtility.TrTextContent("Hide Tool Text");
11 public static readonly GUIContent kShowSpriteMeshOverwriteWarning = new GUIContent(TextContent.showSpriteMeshOverwriteWarning, TextContent.showSpriteMeshOverwriteWarningTip);
12
13 public static bool compactToolBar
14 {
15 get => EditorPrefs.GetBool(kCompactToolbarKey, false);
16 set => EditorPrefs.SetBool(kCompactToolbarKey, value);
17 }
18
19 public static bool showSpriteMeshOverwriteWarning
20 {
21 get => EditorPrefs.GetBool(kShowSpriteMeshOverwriteWarningKey, true);
22 set => EditorPrefs.SetBool(kShowSpriteMeshOverwriteWarningKey, value);
23 }
24
25 public void OnGUI()
26 {
27 EditorGUI.BeginChangeCheck();
28 var c = EditorGUILayout.Toggle(kCompactToolbarLabel, compactToolBar);
29 if (EditorGUI.EndChangeCheck())
30 compactToolBar = c;
31
32 EditorGUI.BeginChangeCheck();
33 c = EditorGUILayout.Toggle(kShowSpriteMeshOverwriteWarning, showSpriteMeshOverwriteWarning);
34 if (EditorGUI.EndChangeCheck())
35 showSpriteMeshOverwriteWarning = c;
36 }
37 }
38
39 internal class VisibilityToolSettings
40 {
41 public const string kBoneOpacitykey = UserSettings.kSettingsUniqueKey + "VisibilityToolSettings.boneOpacity";
42 public const string kMeshOpacityKey = UserSettings.kSettingsUniqueKey + "VisibilityToolSettings.meshOpacity";
43
44 public static float boneOpacity
45 {
46 get => EditorPrefs.GetFloat(kBoneOpacitykey, 1.0f);
47 set => EditorPrefs.SetFloat(kBoneOpacitykey, value);
48 }
49
50 public static float meshOpacity
51 {
52 get => EditorPrefs.GetFloat(kMeshOpacityKey, 0.5f);
53 set => EditorPrefs.SetFloat(kMeshOpacityKey, value);
54 }
55 }
56
57 internal class GenerateGeomertySettings
58 {
59 public const int kDefaultOutlineDetail = 10;
60 public const int kDefaultAlphaTolerance = 10;
61 public const int kDefaultSubdivide = 0;
62 public const string kOutlineDetailKey = UserSettings.kSettingsUniqueKey + "GenerateGeomertySetting.outlineDetail";
63 public const string kAlphaToleranceKey = UserSettings.kSettingsUniqueKey + "GenerateGeomertySetting.alphaTolerance";
64 public const string kSubdivideKey = UserSettings.kSettingsUniqueKey + "GenerateGeomertySetting.subdivide";
65 public const string kGenerateWeightsKey = UserSettings.kSettingsUniqueKey + "GenerateGeomertySetting.generateWeights";
66
67 public static int outlineDetail
68 {
69 get => EditorPrefs.GetInt(kOutlineDetailKey, kDefaultOutlineDetail);
70 set => EditorPrefs.SetInt(kOutlineDetailKey, value);
71 }
72
73 public static int alphaTolerance
74 {
75 get => EditorPrefs.GetInt(kAlphaToleranceKey, kDefaultAlphaTolerance);
76 set => EditorPrefs.SetInt(kAlphaToleranceKey, value);
77 }
78
79 public static int subdivide
80 {
81 get => EditorPrefs.GetInt(kSubdivideKey, kDefaultSubdivide);
82 set => EditorPrefs.SetInt(kSubdivideKey, value);
83 }
84
85 public static bool generateWeights
86 {
87 get => EditorPrefs.GetBool(kGenerateWeightsKey, true);
88 set => EditorPrefs.SetBool(kGenerateWeightsKey, value);
89 }
90 }
91
92 internal class SelectionOutlineSettings
93 {
94 public const string kSelectedOutlineRedKey = UserSettings.kSettingsUniqueKey + "OutlineColorRed";
95 public const string kSelectedOutlineGreenKey = UserSettings.kSettingsUniqueKey + "OutlineColorGreen";
96 public const string kSelectedOutlineBlueKey = UserSettings.kSettingsUniqueKey + "OutlineColorBlue";
97 public const string kSelectedOutlineAlphaKey = UserSettings.kSettingsUniqueKey + "OutlineColorAlpha";
98 public const string kSelectedSpriteOutlineSize = UserSettings.kSettingsUniqueKey + "OutlineSize";
99 public const string kSelectedBoneOutlineSize = UserSettings.kSettingsUniqueKey + "BoneOutlineSize";
100 public static readonly GUIContent kSelectedOutlineColorLabel = new GUIContent(TextContent.selectedOutlineColor);
101 public static readonly GUIContent kSelectedOutlineSizeLabel = new GUIContent(TextContent.spriteOutlineSize);
102 public static readonly GUIContent kSelectedBoneOutlineSizeLabel = new GUIContent(TextContent.boneOutlineSize);
103
104
105 public static Color outlineColor
106 {
107 get =>
108 new()
109 {
110 r = EditorPrefs.GetFloat(kSelectedOutlineRedKey, 1),
111 g = EditorPrefs.GetFloat(kSelectedOutlineGreenKey, 102.0f / 255.0f),
112 b = EditorPrefs.GetFloat(kSelectedOutlineBlueKey, 0),
113 a = EditorPrefs.GetFloat(kSelectedOutlineAlphaKey, 1)
114 };
115 set
116 {
117 EditorPrefs.SetFloat(kSelectedOutlineRedKey, value.r);
118 EditorPrefs.SetFloat(kSelectedOutlineGreenKey, value.g);
119 EditorPrefs.SetFloat(kSelectedOutlineBlueKey, value.b);
120 EditorPrefs.SetFloat(kSelectedOutlineAlphaKey, value.a);
121 }
122 }
123
124 public static int selectedSpriteOutlineSize
125 {
126 get => EditorPrefs.GetInt(kSelectedSpriteOutlineSize, 1);
127 set => EditorPrefs.SetInt(kSelectedSpriteOutlineSize, value);
128 }
129
130 public static float selectedBoneOutlineSize
131 {
132 get => EditorPrefs.GetFloat(kSelectedBoneOutlineSize, 1);
133 set => EditorPrefs.SetFloat(kSelectedBoneOutlineSize, value);
134 }
135
136 public void OnGUI()
137 {
138 EditorGUI.BeginChangeCheck();
139 var c = EditorGUILayout.ColorField(kSelectedOutlineColorLabel, outlineColor);
140 if (EditorGUI.EndChangeCheck())
141 outlineColor = c;
142
143 EditorGUI.BeginChangeCheck();
144 var s = EditorGUILayout.IntSlider(kSelectedOutlineSizeLabel, selectedSpriteOutlineSize, 0, 10);
145 if (EditorGUI.EndChangeCheck())
146 selectedSpriteOutlineSize = s;
147
148 EditorGUI.BeginChangeCheck();
149 var o = EditorGUILayout.Slider(kSelectedBoneOutlineSizeLabel, selectedBoneOutlineSize, 0, 3);
150 if (EditorGUI.EndChangeCheck())
151 selectedBoneOutlineSize = o;
152 }
153 }
154
155 internal class UserSettings : SettingsProvider
156 {
157 public const string kSettingsUniqueKey = "UnityEditor.U2D.Animation/";
158 private static SelectionOutlineSettings s_SelectionOutlineSettings = new SelectionOutlineSettings();
159 private static SkinningModuleSettings s_SkinningModuleSettings = new SkinningModuleSettings();
160
161 public UserSettings()
162 : base("Preferences/2D/Animation", SettingsScope.User)
163 {
164 guiHandler = OnGUI;
165 }
166
167 [SettingsProvider]
168 private static SettingsProvider CreateSettingsProvider()
169 {
170 return new UserSettings()
171 {
172 guiHandler = SettingsGUI
173 };
174 }
175
176 private static void SettingsGUI(string searchContext)
177 {
178 s_SkinningModuleSettings.OnGUI();
179 s_SelectionOutlineSettings.OnGUI();
180 }
181 }
182}