Skip to content

Commit 9a4b7c5

Browse files
committed
feat: reload all CSharpCompilerSettings_* assembly from project settings window
1 parent f815cf2 commit 9a4b7c5

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Editor/AssemblyRenamer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public static void Rename(string dll, string assemblyName)
3232
}
3333

3434
// Start compilation process.
35-
Logger.LogDebug("Rename: Change assembly name\n command={0} {1}\n", psi.FileName, psi.Arguments);
35+
Logger.LogDebug("Rename: Change assembly name ({0})\n command={1} {2}\n", assemblyName, psi.FileName, psi.Arguments);
3636
var p = Process.Start(psi);
3737
p.Exited += (_, __) =>
3838
{
3939
if (p.ExitCode == 0)
40-
Logger.LogDebug("Rename: success.\n{0}", p.StandardOutput.ReadToEnd());
40+
Logger.LogDebug("Rename: success ({0})\n{1}", assemblyName, p.StandardOutput.ReadToEnd());
4141
else
42-
Logger.LogException("Rename: failure.\n{0}\n\n{1}", p.StandardError.ReadToEnd(), p.StandardOutput.ReadToEnd());
42+
Logger.LogException("Rename: failure ({0})\n{1}\n\n{2}", assemblyName, p.StandardError.ReadToEnd(), p.StandardOutput.ReadToEnd());
4343
};
4444
p.EnableRaisingEvents = true;
4545

Editor/CscSettingsProvider.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System.IO;
2+
using System.Linq;
3+
using System.Text.RegularExpressions;
24
using UnityEditor;
35
using UnityEditorInternal;
46
using UnityEngine;
@@ -13,6 +15,11 @@ internal class CscSettingsProvider
1315
private static SerializedProperty s_AnalyzerFilter;
1416
private static ReorderableList s_RoAnalyzerPackages;
1517

18+
private static GUIContent s_HeaderCompiler = new GUIContent("Compiler");
19+
private static GUIContent s_HeaderAnalyzer = new GUIContent("Analyzer");
20+
private static GUIContent s_HeaderDebug = new GUIContent("Debug");
21+
22+
1623
[SettingsProvider]
1724
private static SettingsProvider CreateSettingsProvider()
1825
{
@@ -50,7 +57,7 @@ private static SettingsProvider CreateSettingsProvider()
5057

5158
private static void OnGUI(string searchContext)
5259
{
53-
EditorGUILayout.LabelField("Compiler", EditorStyles.boldLabel);
60+
EditorGUILayout.LabelField(s_HeaderCompiler, EditorStyles.boldLabel);
5461
if (InspectorGUI.DrawCompilerPackage(serializedObject))
5562
{
5663
using (new GUILayout.HorizontalScope())
@@ -66,7 +73,7 @@ private static void OnGUI(string searchContext)
6673

6774
EditorGUILayout.Space();
6875

69-
EditorGUILayout.LabelField("Analyzer", EditorStyles.boldLabel);
76+
EditorGUILayout.LabelField(s_HeaderAnalyzer, EditorStyles.boldLabel);
7077
using (new GUILayout.HorizontalScope())
7178
{
7279
GUILayout.Space(4);
@@ -80,7 +87,7 @@ private static void OnGUI(string searchContext)
8087

8188
EditorGUILayout.Space();
8289

83-
EditorGUILayout.LabelField("Debug", EditorStyles.boldLabel);
90+
EditorGUILayout.LabelField(s_HeaderDebug, EditorStyles.boldLabel);
8491
EditorGUILayout.PropertyField(s_EnableLogging);
8592

8693
// Controls
@@ -91,6 +98,16 @@ private static void OnGUI(string searchContext)
9198
serializedObject.ApplyModifiedProperties();
9299
File.WriteAllText(CscSettingsAsset.k_SettingsPath, JsonUtility.ToJson(serializedObject.targetObject, true));
93100
Utils.RequestCompilation();
101+
},
102+
onReload: () =>
103+
{
104+
if (!EditorUtility.DisplayDialog("Reload all portable CSharpCompilerSettings assemblies", "Reload all CSharpCompilerSettings_***.dll for asmdef files.", "OK", "Cancel")) return;
105+
106+
AssetDatabase.FindAssets("t:DefaultAsset CSharpCompilerSettings_")
107+
.Select(AssetDatabase.GUIDToAssetPath)
108+
.Where(x => Regex.IsMatch(Path.GetFileName(x), "CSharpCompilerSettings_([0-9a-zA-Z]{32}).dll"))
109+
.ToList()
110+
.ForEach(x => InspectorGUI.EnablePortableDll(x, true));
94111
}
95112
);
96113
}

Editor/InspectorGUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public static void DrawControl(bool changed, Action onRevert = null, Action onAp
189189
/// </summary>
190190
/// <param name="asmdefPath">Path of the asmdef</param>
191191
/// <param name="enabled">Condition</param>
192-
private static void EnablePortableDll(string asmdefPath, bool enabled)
192+
public static void EnablePortableDll(string asmdefPath, bool enabled)
193193
{
194194
if (enabled)
195195
{

0 commit comments

Comments
 (0)