-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnityDarkenSettingsEditor.cs
137 lines (113 loc) · 3.7 KB
/
UnityDarkenSettingsEditor.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor;
using UnityEditorInternal;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using Object = UnityEngine.Object;
namespace KS.UnityDarken
{
[CustomEditor( typeof( UnityDarkenSettings ) )]
public class UnityDarkenSettingsEditor : Editor
{
UnityDarkenSettings t;
SerializedProperty styleSheets;
SerializedProperty styleSheetsInverted;
SerializedProperty additiveColors;
SerializedProperty runInvertGui;
SerializedProperty runOnEditorLoad;
SerializedProperty runCreateTextures;
void OnEnable()
{
t = (UnityDarkenSettings)target;
styleSheets = serializedObject.FindProperty( "styleSheets" );
styleSheetsInverted = serializedObject.FindProperty( "styleSheetsInverted" );
additiveColors = serializedObject.FindProperty( "additiveColors" );
runInvertGui = serializedObject.FindProperty( "RunInvertGui" );
runOnEditorLoad = serializedObject.FindProperty( "RunOnEditorLoad" );
runCreateTextures = serializedObject.FindProperty( "RunCreateTextures" );
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField( runOnEditorLoad );
EditorGUILayout.PropertyField( additiveColors );
EditorGUILayout.Space();
if ( GUILayout.Button( "Create All Textures" ) )
t.CreateAllTextures();
if ( GUILayout.Button( "Load Styles From Memory" ) )
t.LoadStyleSheets();
if ( GUILayout.Button( "Set GUI.skin backgrounds to local" ) )
t.SetGUIStylesImageToLocal();
if ( GUILayout.Button( "Set style sheets images to local" ) )
t.SetStyleSheetsImageToLocal();
if ( GUILayout.Button( "Invert All GUI.skin styles" ) )
t.DarkenAllGUIStyles();
if ( runInvertGui.boolValue )
{
runInvertGui.boolValue = false;
t.SetGUIStylesImageToLocal( true );
t.DarkenAllGUIStyles( true );
serializedObject.ApplyModifiedProperties();
t.Refresh();
}
if ( runCreateTextures.boolValue )
{
runCreateTextures.boolValue = false;
t.CreateAllTextures();
t.Refresh();
}
if ( GUILayout.Button( "Darken All" ) )
t.DarkenAll();
if ( GUILayout.Button( "Uncolor All" ) )
t.UncolorAll();
EditorGUILayout.Space();
EditorGUILayout.Space();
EditorGUILayout.LabelField( "Light Sheets:" );
for ( int i = 0; i < styleSheets.arraySize; i++ )
{
using ( SerializedProperty serializedSheet = styleSheets.GetArrayElementAtIndex( i ) )
{
StyleSheet sheet = (StyleSheet)serializedSheet.objectReferenceValue;
if ( sheet == null )
continue;
//var sheetCont = new StyleSheetController(sheet);
//var serialized = new SerializedObject(MyListRef.objectReferenceValue);
EditorGUILayout.BeginHorizontal();
//if (!sheetCont.IsInverted)
//{
EditorGUILayout.LabelField( "- " + sheet.name + " " + sheet.GetHashCode() );
if ( GUILayout.Button( "Darken" ) )
{
t.Darken( sheet, false );
}
//}
EditorGUILayout.EndHorizontal();
}
}
EditorGUILayout.Space();
EditorGUILayout.LabelField( "Inverted Sheets:" );
for ( int i = 0; i < styleSheetsInverted.arraySize; i++ )
{
using ( SerializedProperty serializedSheet = styleSheetsInverted.GetArrayElementAtIndex( i ) )
{
StyleSheet sheet = (StyleSheet)serializedSheet.objectReferenceValue;
EditorGUILayout.BeginHorizontal();
if ( sheet != null )
{
EditorGUILayout.LabelField( "- " + sheet.name + " " + sheet.GetHashCode() ?? "" );
if ( GUILayout.Button( "Uncolor" ) )
{
t.Uncolor( sheet );
}
}
EditorGUILayout.EndHorizontal();
}
}
serializedObject.ApplyModifiedProperties();
}
}
}