Skip to content

Commit 458b6a6

Browse files
committed
make UwcManager.debugMode static not to generate gameobject just by accessing it #9.
1 parent 9290063 commit 458b6a6

File tree

6 files changed

+85
-16
lines changed

6 files changed

+85
-16
lines changed

Assets/uWindowCapture/Editor/UwcEditorUtils.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ public static bool Foldout(string title, bool display)
3333

3434
return display;
3535
}
36+
37+
public static void Fold(string name, ref bool folded, System.Action func)
38+
{
39+
folded = Foldout(name, folded);
40+
if (folded)
41+
{
42+
++EditorGUI.indentLevel;
43+
func();
44+
--EditorGUI.indentLevel;
45+
}
46+
}
3647
}
3748

3849
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
4+
namespace uWindowCapture
5+
{
6+
7+
[CustomEditor(typeof(UwcManager))]
8+
public class UwcManagerEditor : Editor
9+
{
10+
UwcManager manager
11+
{
12+
get { return target as UwcManager; }
13+
}
14+
15+
SerializedProperty windowTitlesUpdateTiming;
16+
17+
void OnEnable()
18+
{
19+
windowTitlesUpdateTiming = serializedObject.FindProperty("windowTitlesUpdateTiming");
20+
}
21+
22+
public override void OnInspectorGUI()
23+
{
24+
serializedObject.Update();
25+
Draw();
26+
serializedObject.ApplyModifiedProperties();
27+
}
28+
29+
void Draw()
30+
{
31+
var debugMode = (DebugMode)EditorGUILayout.EnumPopup("Debug Mode", manager.debugModeFromInspector);
32+
if (debugMode != manager.debugModeFromInspector)
33+
{
34+
manager.debugModeFromInspector = debugMode;
35+
}
36+
37+
EditorGUILayout.PropertyField(windowTitlesUpdateTiming);
38+
}
39+
}
40+
41+
}

Assets/uWindowCapture/Editor/UwcManagerEditor.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/uWindowCapture/Editor/UwcWindowTextureEditor.cs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,6 @@ string error
5050
SerializedProperty scaleControlType;
5151
SerializedProperty scalePer1000Pixel;
5252

53-
void Fold(string name, ref bool folded, System.Action func)
54-
{
55-
folded = EditorUtils.Foldout(name, folded);
56-
if (folded)
57-
{
58-
++EditorGUI.indentLevel;
59-
func();
60-
--EditorGUI.indentLevel;
61-
}
62-
}
63-
6453
void OnEnable()
6554
{
6655
updateTitle = serializedObject.FindProperty("updateTitle");
@@ -82,10 +71,10 @@ public override void OnInspectorGUI()
8271
serializedObject.Update();
8372
{
8473
EditorGUILayout.Space();
85-
Fold("Target", ref targetFold_, () => { DrawTargetSettings(); });
86-
Fold("Capture Settings", ref captureSettingFold_, () => { DrawCaptureSettings(); });
87-
Fold("Scale Settings", ref scaleSettingFold_, () => { DrawScaleSettings(); });
88-
Fold("Window Information", ref windowInformationFold_, () => { DrawWindowInformation(); });
74+
EditorUtils.Fold("Target", ref targetFold_, () => { DrawTargetSettings(); });
75+
EditorUtils.Fold("Capture Settings", ref captureSettingFold_, () => { DrawCaptureSettings(); });
76+
EditorUtils.Fold("Scale Settings", ref scaleSettingFold_, () => { DrawScaleSettings(); });
77+
EditorUtils.Fold("Window Information", ref windowInformationFold_, () => { DrawWindowInformation(); });
8978
}
9079
serializedObject.ApplyModifiedProperties();
9180

Assets/uWindowCapture/Scripts/UwcManager.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,24 @@ public static void CreateManagerGameObject()
3939
}
4040
#endif
4141

42-
public DebugMode debugMode = DebugMode.File;
42+
public DebugMode debugModeFromInspector = DebugMode.File;
43+
private static DebugMode debugModeFromScript = DebugMode.File;
44+
private static bool debugModeChangedFromScript = false;
45+
public static DebugMode debugMode
46+
{
47+
get
48+
{
49+
return debugModeChangedFromScript ?
50+
debugModeFromScript :
51+
instance.debugModeFromInspector;
52+
}
53+
set
54+
{
55+
debugModeFromScript = value;
56+
debugModeChangedFromScript = true;
57+
}
58+
}
59+
4360
public static event Lib.DebugLogDelegate onDebugLog = OnDebugLog;
4461
public static event Lib.DebugLogDelegate onDebugErr = OnDebugErr;
4562
[AOT.MonoPInvokeCallback(typeof(Lib.DebugLogDelegate))]
100 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)