Skip to content

Commit 0ccdb01

Browse files
committed
initial version
0 parents  commit 0ccdb01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+6792
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/[Ll]ibrary/
2+
/[Tt]emp/
3+
/[Oo]bj/
4+
/[Bb]uild/
5+
/[Bb]uilds/
6+
/[Ll]ogs/
7+
/[Uu]ser[Ss]ettings/
8+
.vs/
9+
.gradle/
10+
*.csproj
11+
*.sln
12+
*.suo

Assets/CustomExample.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Analysis.GraphicsTuner;
2+
using UnityEngine;
3+
4+
public class CustomExample : MonoBehaviour {
5+
private void Start() {
6+
var tuner = GraphicsTuner.Instance;
7+
if (tuner == null) return;
8+
9+
tuner.BasicSetting.SetActive(false);
10+
11+
var setting = tuner.CreateCustomSettings("Custom");
12+
setting.CreateToggle(
13+
"HDR",
14+
() => Camera.main.allowHDR,
15+
(v) => Camera.main.allowHDR = v
16+
);
17+
}
18+
}

Assets/CustomExample.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.

Assets/GraphicsTuner.meta

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

Assets/GraphicsTuner/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using Analysis.GraphicsTuner.Module;
2+
using UnityEditor;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
6+
namespace Analysis.GraphicsTuner {
7+
[CustomEditor(typeof(GraphicsTuner))]
8+
public class GraphicsTunerInspector : Editor {
9+
10+
private const int PADDING = 30;
11+
private const int TOGGLE_WIDTH = 100;
12+
13+
public override void OnInspectorGUI() {
14+
this.DrawSwitchAnchor();
15+
this.DrawModuleSetting();
16+
}
17+
18+
private void DrawSwitchAnchor() {
19+
var switchBtn = (Button)serializedObject.FindProperty("switchBtn").objectReferenceValue;
20+
var rect = switchBtn.GetComponent<RectTransform>();
21+
22+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
23+
EditorGUILayout.LabelField("Anchor", EditorStyles.toolbarButton);
24+
EditorGUILayout.Space();
25+
26+
EditorGUILayout.BeginHorizontal();
27+
GUILayout.FlexibleSpace();
28+
// Top Left
29+
if (GUILayout.Toggle(rect.anchorMin == Vector2.up && rect.anchorMax == Vector2.up, "Top-Left", EditorStyles.toolbarButton, GUILayout.Width(TOGGLE_WIDTH))) {
30+
rect.anchorMin = Vector2.up;
31+
rect.anchorMax = Vector2.up;
32+
rect.anchoredPosition = new Vector3(PADDING, -PADDING);
33+
}
34+
// Top Right
35+
if (GUILayout.Toggle(rect.anchorMin == Vector2.one && rect.anchorMax == Vector2.one, "Top-Right", EditorStyles.toolbarButton, GUILayout.Width(TOGGLE_WIDTH))) {
36+
rect.anchorMin = Vector2.one;
37+
rect.anchorMax = Vector2.one;
38+
rect.anchoredPosition = new Vector3(-PADDING, -PADDING);
39+
}
40+
GUILayout.FlexibleSpace();
41+
EditorGUILayout.EndHorizontal();
42+
43+
EditorGUILayout.BeginHorizontal();
44+
GUILayout.FlexibleSpace();
45+
// Bottom Left
46+
if (GUILayout.Toggle(rect.anchorMin == Vector2.zero && rect.anchorMax == Vector2.zero, "Bottom-Left", EditorStyles.toolbarButton, GUILayout.Width(TOGGLE_WIDTH))) {
47+
rect.anchorMin = Vector2.zero;
48+
rect.anchorMax = Vector2.zero;
49+
rect.anchoredPosition = new Vector3(PADDING, PADDING);
50+
}
51+
// Bottom Right
52+
if (GUILayout.Toggle(rect.anchorMin == Vector2.right && rect.anchorMax == Vector2.right, "Bottom-Right", EditorStyles.toolbarButton, GUILayout.Width(TOGGLE_WIDTH))) {
53+
rect.anchorMin = Vector2.right;
54+
rect.anchorMax = Vector2.right;
55+
rect.anchoredPosition = new Vector3(-PADDING, PADDING);
56+
}
57+
GUILayout.FlexibleSpace();
58+
EditorGUILayout.EndHorizontal();
59+
60+
EditorGUILayout.Space();
61+
EditorGUILayout.EndVertical();
62+
}
63+
64+
private void DrawModuleSetting() {
65+
var tuner = (GraphicsTuner)this.target;
66+
if (tuner.Modules != null) {
67+
for (int i = 0; i < tuner.Modules.Count; i++) {
68+
this.DrawModuleSetting(tuner.Modules[i]);
69+
}
70+
}
71+
}
72+
73+
private void DrawModuleSetting(SettingModule module) {
74+
if (module == null) return;
75+
76+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
77+
EditorGUILayout.LabelField(module.name, EditorStyles.toolbarButton);
78+
EditorGUILayout.Space();
79+
80+
var active = EditorGUILayout.Toggle("Enable", module.isActive);
81+
if (active != module.isActive) {
82+
module.SetActive(active);
83+
}
84+
85+
var anchor = (ComponentAnchor)EditorGUILayout.EnumPopup("Anchor", module.anchor);
86+
if (anchor != module.anchor) {
87+
module.SetAnchor(anchor);
88+
}
89+
90+
EditorGUILayout.Space();
91+
EditorGUILayout.EndVertical();
92+
}
93+
}
94+
}

Assets/GraphicsTuner/Editor/GraphicsTunerInspector.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)