com.amanotes.gdk 0.2.97 → 0.2.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/Editor/AmaGDK.Editor.asmdef +2 -1
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AutoEventQC.unitypackage +0 -0
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/Consent.unitypackage +0 -0
- package/Extra/CrashlyticHook.unitypackage +0 -0
- package/Extra/ForceUpdate.unitypackage +0 -0
- package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
- package/Extra/PostProcessor.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
- package/Runtime/Ad/AmaGDK.Ads.cs +18 -0
- package/Runtime/AmaGDK.IAP.cs +8 -0
- package/Runtime/AmaGDK.asmdef +2 -1
- package/Runtime/AmaGDK.cs +1 -103
- package/package.json +7 -3
- package/Editor/Extra/GDKLocalBuild.cs +0 -910
- package/Editor/Extra/GDKLocalBuild.cs.meta +0 -3
- package/Editor/Extra/GDKProjectCP.cs +0 -216
- package/Editor/Extra/GDKProjectCP.cs.meta +0 -11
- package/Editor/Extra/GDKSymbolDefine.cs +0 -396
- package/Editor/Extra/GDKSymbolDefine.cs.meta +0 -11
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
using Amanotes.Core.Internal;
|
|
2
|
-
using System.Collections.Generic;
|
|
3
|
-
using UnityEditor;
|
|
4
|
-
using UnityEngine;
|
|
5
|
-
using System.Linq;
|
|
6
|
-
using UnityEditor.SceneManagement;
|
|
7
|
-
|
|
8
|
-
namespace Amanotes
|
|
9
|
-
{
|
|
10
|
-
internal class GDKProjectCP : EditorWindow
|
|
11
|
-
{
|
|
12
|
-
private static GDKProjectCP _window;
|
|
13
|
-
static Texture2D iconScene;
|
|
14
|
-
static Texture2D iconPlay;
|
|
15
|
-
static Texture2D iconFolder;
|
|
16
|
-
static GUIStyle productNameStyle;
|
|
17
|
-
static string projectPath;
|
|
18
|
-
|
|
19
|
-
private static int activeSceneIndex;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
[MenuItem("Window/AmaGDK/Project Control Panel")]
|
|
23
|
-
private static void ShowWindow()
|
|
24
|
-
{
|
|
25
|
-
if (_window != null) return;
|
|
26
|
-
|
|
27
|
-
iconScene = AssetPreview.GetMiniTypeThumbnail(typeof(SceneAsset));
|
|
28
|
-
_window = CreateInstance<GDKProjectCP>();
|
|
29
|
-
_window.titleContent = new GUIContent("Project CP", iconScene, "GDK Project Control Panel");
|
|
30
|
-
_window.Show();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
void Init()
|
|
34
|
-
{
|
|
35
|
-
if (iconScene == null) iconScene = AssetPreview.GetMiniTypeThumbnail(typeof(SceneAsset));
|
|
36
|
-
iconPlay = EditorGUIUtility.FindTexture("PlayButton");
|
|
37
|
-
iconFolder = EditorGUIUtility.FindTexture("Folder Icon");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
productNameStyle = new GUIStyle(EditorStyles.largeLabel)
|
|
41
|
-
{
|
|
42
|
-
alignment = TextAnchor.MiddleCenter,
|
|
43
|
-
fontSize = 32
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
projectPath = Application.dataPath;
|
|
47
|
-
List<string> arr = projectPath.Split('/').ToList();
|
|
48
|
-
arr.RemoveAt(arr.Count - 1);
|
|
49
|
-
|
|
50
|
-
if (arr.Count > 3)
|
|
51
|
-
{
|
|
52
|
-
arr.RemoveRange(0, arr.Count - 3);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
projectPath = string.Join("/", arr);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static void DrawBigPlayButton()
|
|
59
|
-
{
|
|
60
|
-
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
|
|
61
|
-
if (scenes.Length == 0)
|
|
62
|
-
{
|
|
63
|
-
EditorGUILayout.HelpBox("No scene in Build Setting!", MessageType.Warning);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
EditorBuildSettingsScene scene = scenes[activeSceneIndex];
|
|
68
|
-
|
|
69
|
-
GUILayout.BeginHorizontal();
|
|
70
|
-
{
|
|
71
|
-
EditorGUILayout.Space();
|
|
72
|
-
GUILayout.BeginVertical();
|
|
73
|
-
{
|
|
74
|
-
GUILayout.Space(16);
|
|
75
|
-
GUILayout.Label(scene.path);
|
|
76
|
-
activeSceneIndex = EditorGUILayout.IntSlider(activeSceneIndex, 0, scenes.Length - 1);
|
|
77
|
-
}
|
|
78
|
-
GUILayout.EndVertical();
|
|
79
|
-
if (GUILayout.Button(iconPlay, GUILayout.Width(64f), GUILayout.Height(64f)))
|
|
80
|
-
{
|
|
81
|
-
OpenScene(scene.path, true);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
GUILayout.EndHorizontal();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static void OpenScene(string scenePath, bool play)
|
|
88
|
-
{
|
|
89
|
-
if (EditorApplication.isPlaying)
|
|
90
|
-
{
|
|
91
|
-
EditorApplication.isPlaying = false;
|
|
92
|
-
}
|
|
93
|
-
else
|
|
94
|
-
{
|
|
95
|
-
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
|
|
96
|
-
EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
|
|
97
|
-
if (play) EditorApplication.isPlaying = true;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
static void DrawProjectInfo()
|
|
102
|
-
{
|
|
103
|
-
GUILayout.Label(PlayerSettings.productName, productNameStyle);
|
|
104
|
-
|
|
105
|
-
var projectPathContent = new GUIContent(projectPath, iconFolder, "click to open folder");
|
|
106
|
-
|
|
107
|
-
if (GUILayout.Button(projectPathContent, EditorStyles.toolbarButton))
|
|
108
|
-
{
|
|
109
|
-
EditorUtility.RevealInFinder(Application.dataPath);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
static void DrawListScenes()
|
|
114
|
-
{
|
|
115
|
-
EditorBuildSettingsScene[] listScenes = EditorBuildSettings.scenes;
|
|
116
|
-
int n = Mathf.Min(listScenes.Length, listScenes.Length);
|
|
117
|
-
|
|
118
|
-
GUILayout.BeginVertical();
|
|
119
|
-
{
|
|
120
|
-
for (var i = 0; i < n; i++)
|
|
121
|
-
{
|
|
122
|
-
EditorBuildSettingsScene scene = listScenes[i];
|
|
123
|
-
if (!scene.enabled) continue;
|
|
124
|
-
|
|
125
|
-
GUILayout.BeginHorizontal();
|
|
126
|
-
{
|
|
127
|
-
var asset = AssetDatabase.LoadAssetAtPath<SceneAsset>(scene.path);
|
|
128
|
-
|
|
129
|
-
if (GUILayout.Button(iconScene, EditorStyles.toolbarButton, GUILayout.Width(25f)))
|
|
130
|
-
{
|
|
131
|
-
OpenScene(scene.path, false);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
EditorGUILayout.ObjectField(asset, typeof(SceneAsset), false);
|
|
135
|
-
|
|
136
|
-
if (GUILayout.Button(iconPlay, EditorStyles.toolbarButton, GUILayout.Width(25f)))
|
|
137
|
-
{
|
|
138
|
-
OpenScene(scene.path, true);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
GUILayout.EndHorizontal();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
GUILayout.EndVertical();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
public void OnGUI()
|
|
149
|
-
{
|
|
150
|
-
if (productNameStyle == null) Init();
|
|
151
|
-
|
|
152
|
-
DrawProjectInfo();
|
|
153
|
-
|
|
154
|
-
if (EditorApplication.isPlayingOrWillChangePlaymode)
|
|
155
|
-
{
|
|
156
|
-
// EditorGUILayout.HelpBox("Application is Playing!", MessageType.Info);
|
|
157
|
-
DrawRuntimeGUI();
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
EditorGUILayout.Space();
|
|
162
|
-
DrawBigPlayButton();
|
|
163
|
-
EditorGUILayout.Space();
|
|
164
|
-
DrawListScenes();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
private readonly List<float> FPS = new List<float>()
|
|
169
|
-
{
|
|
170
|
-
0, 1, 5, 10, 15, 20, 30, 45, 50, 60, 75, 90, 120, 240, 360, 480, 720, 960, 1000, 1200
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
private readonly List<float> TIMESCALES = new List<float>()
|
|
174
|
-
{
|
|
175
|
-
0f, 0.1f, 0.2f, 0.5f, 1f, 2f, 5f, 10f
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
void DrawRuntimeGUI()
|
|
179
|
-
{
|
|
180
|
-
float fps = Application.targetFrameRate;
|
|
181
|
-
if (DrawSlider2("Target FPS", ref fps, FPS))
|
|
182
|
-
{
|
|
183
|
-
Application.targetFrameRate = (int)fps;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
float ts = Time.timeScale;
|
|
187
|
-
if (DrawSlider2("Time Scale", ref ts, TIMESCALES))
|
|
188
|
-
{
|
|
189
|
-
Time.timeScale = ts;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
bool DrawSlider2(string label, ref float v, List<float> values)
|
|
194
|
-
{
|
|
195
|
-
int idx1 = values.IndexOf(v);
|
|
196
|
-
if (idx1 == -1)
|
|
197
|
-
{
|
|
198
|
-
values.Add(v);
|
|
199
|
-
values.Sort();
|
|
200
|
-
idx1 = values.IndexOf(v);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
int idx2;
|
|
204
|
-
GUILayout.BeginHorizontal();
|
|
205
|
-
{
|
|
206
|
-
GUILayout.Label(label, GUILayout.Width(100f));
|
|
207
|
-
idx2 = Mathf.RoundToInt(GUILayout.HorizontalSlider(idx1, 0, values.Count - 1));
|
|
208
|
-
GUILayout.Label($"{v}", GUILayout.Width(50f));
|
|
209
|
-
}
|
|
210
|
-
GUILayout.EndHorizontal();
|
|
211
|
-
if (idx2 == idx1) return false;
|
|
212
|
-
v = values[idx2];
|
|
213
|
-
return true;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using System.Collections.Generic;
|
|
3
|
-
using System.IO;
|
|
4
|
-
using System.Linq;
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
using UnityEditor;
|
|
7
|
-
using UnityEngine.Serialization;
|
|
8
|
-
using UnityObject = UnityEngine.Object;
|
|
9
|
-
|
|
10
|
-
namespace Amanotes.Core
|
|
11
|
-
{
|
|
12
|
-
[CreateAssetMenu(fileName = "GDKSymbolDefine", menuName = "Ama GDK/GDK Symbol Define", order = 100)]
|
|
13
|
-
internal partial class GDKSymbolDefine : ScriptableObject
|
|
14
|
-
{
|
|
15
|
-
private static readonly string cscRspFilePath = "Assets/csc.rsp";
|
|
16
|
-
public List<SymbolInfo> symbols = new List<SymbolInfo>();
|
|
17
|
-
public LoggerConfig loggerConfig = new LoggerConfig();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
[ContextMenu("Read")]
|
|
21
|
-
public void Read()
|
|
22
|
-
{
|
|
23
|
-
if (!File.Exists(cscRspFilePath)) return;
|
|
24
|
-
|
|
25
|
-
var enabledSymbols = new HashSet<string>(ReadCSC());
|
|
26
|
-
AddSymbol(enabledSymbols, true);
|
|
27
|
-
SetEnableSymbols(enabledSymbols, true);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private void Write()
|
|
31
|
-
{
|
|
32
|
-
var list = symbols
|
|
33
|
-
.Union(this.loggerConfig.tags)
|
|
34
|
-
.Where(item=>item.enabled)
|
|
35
|
-
.Select(item => item.name)
|
|
36
|
-
.Distinct()
|
|
37
|
-
.ToArray();
|
|
38
|
-
|
|
39
|
-
string content = list.Length > 0 ? $"-define:{string.Join(";", list)}" : string.Empty;
|
|
40
|
-
File.WriteAllText(cscRspFilePath, content);
|
|
41
|
-
AssetDatabase.Refresh();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
[ContextMenu("Apply")]
|
|
45
|
-
public void Apply()
|
|
46
|
-
{
|
|
47
|
-
Write();
|
|
48
|
-
loggerConfig.GenerateLogger();
|
|
49
|
-
|
|
50
|
-
#if UNITY_EDITOR
|
|
51
|
-
EditorUtility.SetDirty((this));
|
|
52
|
-
AssetDatabase.Refresh();
|
|
53
|
-
#endif
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private void SetEnableSymbols(HashSet<string> enabledSymbols, bool enabled)
|
|
57
|
-
{
|
|
58
|
-
for (var i = 0; i < symbols.Count; i++)
|
|
59
|
-
{
|
|
60
|
-
symbols[i].enabled = enabledSymbols.Contains(symbols[i].name);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
for (var i = 0; i < loggerConfig.tags.Count; i++)
|
|
64
|
-
{
|
|
65
|
-
loggerConfig.tags[i].enabled = enabledSymbols.Contains(loggerConfig.tags[i].name);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private void AddSymbol(IEnumerable<string> newSymbols, bool enabled)
|
|
70
|
-
{
|
|
71
|
-
var dict = symbols
|
|
72
|
-
.Union(loggerConfig.tags)
|
|
73
|
-
.Distinct()
|
|
74
|
-
.ToDictionary(item => item.name);
|
|
75
|
-
|
|
76
|
-
foreach (string symbol in newSymbols)
|
|
77
|
-
{
|
|
78
|
-
if (dict.TryGetValue(symbol, out var info)) continue;
|
|
79
|
-
info = new SymbolInfo() { name = symbol, enabled = enabled };
|
|
80
|
-
symbols.Add(info);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
#if UNITY_EDITOR
|
|
84
|
-
EditorUtility.SetDirty(this);
|
|
85
|
-
#endif
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private List<string> ReadCSC()
|
|
89
|
-
{
|
|
90
|
-
var result = new List<string>();
|
|
91
|
-
if (!File.Exists(cscRspFilePath)) return result;
|
|
92
|
-
string[] rspLines = File.ReadAllLines(cscRspFilePath);
|
|
93
|
-
|
|
94
|
-
foreach (string line in rspLines)
|
|
95
|
-
{
|
|
96
|
-
string line2 = line.Trim();
|
|
97
|
-
if (!line2.StartsWith("-define:")) continue;
|
|
98
|
-
|
|
99
|
-
// Extract existing symbols from -define:
|
|
100
|
-
result.AddRange(line2.Substring(8).Split(';'));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
internal partial class GDKSymbolDefine
|
|
108
|
-
{
|
|
109
|
-
[Serializable] internal class SymbolInfo
|
|
110
|
-
{
|
|
111
|
-
[FormerlySerializedAs("symbol")] public string name;
|
|
112
|
-
public bool enabled;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
[Serializable] internal class LoggerConfig
|
|
116
|
-
{
|
|
117
|
-
public bool enabled;
|
|
118
|
-
public bool forceCleanUp;
|
|
119
|
-
public UnityObject codeGenerateFolder;
|
|
120
|
-
public string codeGeneratePath
|
|
121
|
-
{
|
|
122
|
-
get
|
|
123
|
-
{
|
|
124
|
-
string path = AssetDatabase.GetAssetPath(codeGenerateFolder);
|
|
125
|
-
if (AssetDatabase.IsValidFolder(path)) return path;
|
|
126
|
-
|
|
127
|
-
var defaultPath = "Assets/AmaGDK/LogV2";
|
|
128
|
-
var asset = AssetDatabase.LoadAssetAtPath<UnityObject>(defaultPath);
|
|
129
|
-
if (asset != null) codeGenerateFolder = asset;
|
|
130
|
-
return defaultPath;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
public string className = "LogV2";
|
|
134
|
-
|
|
135
|
-
[HideInInspector][SerializeField] private string classTemplate = $@"using Debug = UnityEngine.Debug;
|
|
136
|
-
using UnityObject = UnityEngine.Object;
|
|
137
|
-
|
|
138
|
-
public partial class $$CLASS_NAME$$
|
|
139
|
-
{{
|
|
140
|
-
private static void Log(string tag, string message, UnityObject context)
|
|
141
|
-
{{
|
|
142
|
-
Debug.Log($""[{{tag}}] {{message}}"", context);
|
|
143
|
-
}}
|
|
144
|
-
|
|
145
|
-
private static void LogWarning(string tag, string message, UnityObject context)
|
|
146
|
-
{{
|
|
147
|
-
Debug.LogWarning($""[{{tag}}] {{message}}"", context);
|
|
148
|
-
}}
|
|
149
|
-
|
|
150
|
-
private static void LogError(string tag, string message, UnityObject context)
|
|
151
|
-
{{
|
|
152
|
-
Debug.LogError($""[{{tag}}] {{message}}"", context);
|
|
153
|
-
}}
|
|
154
|
-
}}";
|
|
155
|
-
|
|
156
|
-
public List<SymbolInfo> tags = new List<SymbolInfo>();
|
|
157
|
-
|
|
158
|
-
public void GenerateLogger()
|
|
159
|
-
{
|
|
160
|
-
if (!enabled) return;
|
|
161
|
-
|
|
162
|
-
bool hasFolder = Directory.Exists(codeGeneratePath);
|
|
163
|
-
if (hasFolder)
|
|
164
|
-
{
|
|
165
|
-
if (forceCleanUp)
|
|
166
|
-
{
|
|
167
|
-
Directory.Delete(codeGeneratePath, true);
|
|
168
|
-
hasFolder = false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (!hasFolder) Directory.CreateDirectory(codeGeneratePath);
|
|
173
|
-
|
|
174
|
-
// Generate main logger class
|
|
175
|
-
string filePath = Path.Combine(codeGeneratePath, $"{className}.cs");
|
|
176
|
-
string classContent;
|
|
177
|
-
|
|
178
|
-
if (!File.Exists(filePath))
|
|
179
|
-
{
|
|
180
|
-
classContent = classTemplate.Replace("$$CLASS_NAME$$", className);
|
|
181
|
-
File.WriteAllText(filePath, classContent);
|
|
182
|
-
AssetDatabase.ImportAsset(filePath);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Generate derived logger classes
|
|
186
|
-
for (var i = 0; i < tags.Count; i++)
|
|
187
|
-
{
|
|
188
|
-
string tag = tags[i].name;
|
|
189
|
-
classContent = GenerateTagClassContent(tag);
|
|
190
|
-
filePath = Path.Combine(codeGeneratePath, $"{className}.{tag}.cs");
|
|
191
|
-
File.WriteAllText(filePath, classContent);
|
|
192
|
-
AssetDatabase.ImportAsset(filePath);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
private string GenerateTagClassContent(string tag)
|
|
197
|
-
{
|
|
198
|
-
return $@"using System.Diagnostics;
|
|
199
|
-
using UnityObject = UnityEngine.Object;
|
|
200
|
-
|
|
201
|
-
public partial class {className}
|
|
202
|
-
{{
|
|
203
|
-
public static class {tag}
|
|
204
|
-
{{
|
|
205
|
-
[Conditional(nameof({tag}))]
|
|
206
|
-
public static void Log(string message, UnityObject context = null) => {className}.Log(nameof({tag}), message, context);
|
|
207
|
-
|
|
208
|
-
[Conditional(nameof({tag}))]
|
|
209
|
-
public static void LogWarning(string message, UnityObject context = null) => {className}.LogWarning(nameof({tag}),message, context);
|
|
210
|
-
|
|
211
|
-
[Conditional(nameof({tag}))]
|
|
212
|
-
public static void LogError(string message, UnityObject context = null) => {className}.LogError(nameof({tag}), message, context);
|
|
213
|
-
}}
|
|
214
|
-
}}";
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
// INSPECTOR
|
|
221
|
-
|
|
222
|
-
[CustomPropertyDrawer(typeof(GDKSymbolDefine.SymbolInfo))]
|
|
223
|
-
internal class SymbolInfoDrawer : PropertyDrawer
|
|
224
|
-
{
|
|
225
|
-
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
|
226
|
-
{
|
|
227
|
-
// Begin property drawing
|
|
228
|
-
EditorGUI.BeginProperty(position, label, property);
|
|
229
|
-
|
|
230
|
-
// Calculate rects
|
|
231
|
-
var toggleRect = new Rect(position.x, position.y, 20, position.height);
|
|
232
|
-
var labelRect = new Rect(position.x + 25, position.y, position.width - 25, position.height);
|
|
233
|
-
|
|
234
|
-
// Draw fields
|
|
235
|
-
SerializedProperty symbolProperty = property.FindPropertyRelative("name");
|
|
236
|
-
SerializedProperty enabledProperty = property.FindPropertyRelative("enabled");
|
|
237
|
-
|
|
238
|
-
// Draw the enabled toggle
|
|
239
|
-
enabledProperty.boolValue = EditorGUI.Toggle(toggleRect, enabledProperty.boolValue);
|
|
240
|
-
|
|
241
|
-
// Draw the symbol name field
|
|
242
|
-
symbolProperty.stringValue = EditorGUI.TextField(labelRect, symbolProperty.stringValue, EditorStyles.label);
|
|
243
|
-
|
|
244
|
-
// End property drawing
|
|
245
|
-
EditorGUI.EndProperty();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
[CustomEditor(typeof(GDKSymbolDefine))]
|
|
250
|
-
public class GDKSymbolDefineEditor : UnityEditor.Editor
|
|
251
|
-
{
|
|
252
|
-
private SerializedProperty symbolsProp;
|
|
253
|
-
private SerializedProperty loggerConfigProp;
|
|
254
|
-
private int selectedTab = 0;
|
|
255
|
-
private GDKSymbolDefine define;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
private readonly GUIContent[] tabTitles = new GUIContent[]
|
|
259
|
-
{
|
|
260
|
-
new GUIContent("Symbols"),
|
|
261
|
-
new GUIContent("Logger Config")
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
private void OnEnable()
|
|
265
|
-
{
|
|
266
|
-
define = (GDKSymbolDefine)target;
|
|
267
|
-
symbolsProp = serializedObject.FindProperty("symbols");
|
|
268
|
-
loggerConfigProp = serializedObject.FindProperty("loggerConfig");
|
|
269
|
-
define.Read();
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
public override void OnInspectorGUI()
|
|
273
|
-
{
|
|
274
|
-
if (Application.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode)
|
|
275
|
-
{
|
|
276
|
-
EditorGUILayout.HelpBox("Disabled in play mode!", MessageType.Info);
|
|
277
|
-
Repaint();
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (EditorApplication.isUpdating)
|
|
282
|
-
{
|
|
283
|
-
EditorGUILayout.HelpBox("Please wait for Unity Editor to finish importing!", MessageType.Info);
|
|
284
|
-
Repaint();
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (EditorApplication.isCompiling)
|
|
289
|
-
{
|
|
290
|
-
EditorGUILayout.HelpBox("Please wait for Unity Editor to finish compiling!", MessageType.Info);
|
|
291
|
-
Repaint();
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (define == null) return;
|
|
296
|
-
|
|
297
|
-
serializedObject.Update();
|
|
298
|
-
selectedTab = GUILayout.Toolbar(selectedTab, tabTitles, GUILayout.Height(32f));
|
|
299
|
-
|
|
300
|
-
switch (selectedTab)
|
|
301
|
-
{
|
|
302
|
-
case 0:
|
|
303
|
-
DrawSymbolsTab();
|
|
304
|
-
break;
|
|
305
|
-
case 1:
|
|
306
|
-
DrawLoggerConfigTab();
|
|
307
|
-
break;
|
|
308
|
-
default:
|
|
309
|
-
DrawSymbolsTab();
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
GUILayout.Space(24f);
|
|
314
|
-
if (GUILayout.Button("Apply", GUILayout.Height(30f)))
|
|
315
|
-
{
|
|
316
|
-
define.Apply();
|
|
317
|
-
Repaint();
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
serializedObject.ApplyModifiedProperties();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
private void DrawSymbolsTab()
|
|
324
|
-
{
|
|
325
|
-
EditorGUILayout.PropertyField(symbolsProp, new GUIContent("DEFINE SYMBOLS"), true);
|
|
326
|
-
if (!define.loggerConfig.enabled) return;
|
|
327
|
-
|
|
328
|
-
GUILayout.BeginHorizontal();
|
|
329
|
-
{
|
|
330
|
-
if (GUILayout.Button("Select All"))
|
|
331
|
-
{
|
|
332
|
-
SetSelection(true);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (GUILayout.Button("Deselect All"))
|
|
336
|
-
{
|
|
337
|
-
SetSelection(false);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
GUILayout.EndHorizontal();
|
|
341
|
-
|
|
342
|
-
EditorGUILayout.PropertyField(loggerConfigProp.FindPropertyRelative("tags"), new GUIContent("LOGGER TAGS"), true);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
private void SetSelection(bool isOn)
|
|
346
|
-
{
|
|
347
|
-
var tags = define.loggerConfig.tags;
|
|
348
|
-
for (var i = 0; i < tags.Count; i++)
|
|
349
|
-
{
|
|
350
|
-
tags[i].enabled = isOn;
|
|
351
|
-
}
|
|
352
|
-
EditorUtility.SetDirty(target);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
private static bool showTemplate = false;
|
|
356
|
-
private void DrawLoggerConfigTab()
|
|
357
|
-
{
|
|
358
|
-
// EditorGUILayout.PropertyField(loggerConfigProp, GUIContent.none, true);
|
|
359
|
-
DrawProperty(serializedObject, "loggerConfig", true);
|
|
360
|
-
showTemplate = GUILayout.Toggle(showTemplate, "Logger class template", EditorStyles.foldout);
|
|
361
|
-
if (showTemplate)
|
|
362
|
-
{
|
|
363
|
-
var prop = serializedObject
|
|
364
|
-
.FindProperty("loggerConfig")
|
|
365
|
-
.FindPropertyRelative("classTemplate");
|
|
366
|
-
EditorGUILayout.PropertyField(prop, GUIContent.none, false, GUILayout.Height(16 * 20));
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
private static void DrawProperty(SerializedObject so, string propertyField, bool childrenOnly)
|
|
371
|
-
{
|
|
372
|
-
SerializedProperty property = so.FindProperty(propertyField);
|
|
373
|
-
if (property == null)
|
|
374
|
-
{
|
|
375
|
-
EditorGUILayout.HelpBox($"Property not found <{propertyField}>!", MessageType.Warning);
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (!childrenOnly)
|
|
380
|
-
{
|
|
381
|
-
EditorGUILayout.PropertyField(property);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
string basePath = property.propertyPath;
|
|
385
|
-
var first = true;
|
|
386
|
-
while (property.NextVisible(first))
|
|
387
|
-
{
|
|
388
|
-
first = false;
|
|
389
|
-
if (!property.propertyPath.Contains(basePath)) break;
|
|
390
|
-
EditorGUILayout.PropertyField(property);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
so.ApplyModifiedProperties();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|