Skip to content

Commit 74c1c96

Browse files
committed
Allow multiple un/loadTrigger attributes, use action to trigger repaints
1 parent 34a6b01 commit 74c1c96

3 files changed

Lines changed: 15 additions & 22 deletions

File tree

scripts/DllManipulator.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,16 @@ internal static void Initialize(int unityMainThreadId, string assetsPath)
8181
if (Options.mockAllNativeFunctions || method.IsDefined(typeof(MockNativeDeclarationAttribute)) || method.DeclaringType.IsDefined(typeof(MockNativeDeclarationsAttribute)))
8282
MockNativeFunction(method);
8383
}
84-
else if(method.IsDefined(typeof(NativeDllLoadedTriggerAttribute)))
84+
else
8585
{
86-
RegisterTriggerMethod(method, ref _customLoadedTriggers);
87-
}
88-
else if (method.IsDefined(typeof(NativeDllBeforeUnloadTriggerAttribute)))
89-
{
90-
RegisterTriggerMethod(method, ref _customBeforeUnloadTriggers);
91-
}
92-
else if (method.IsDefined(typeof(NativeDllAfterUnloadTriggerAttribute)))
93-
{
94-
RegisterTriggerMethod(method, ref _customAfterUnloadTriggers);
86+
if (method.IsDefined(typeof(NativeDllLoadedTriggerAttribute)))
87+
RegisterTriggerMethod(method, ref _customLoadedTriggers);
88+
89+
if (method.IsDefined(typeof(NativeDllBeforeUnloadTriggerAttribute)))
90+
RegisterTriggerMethod(method, ref _customBeforeUnloadTriggers);
91+
92+
if (method.IsDefined(typeof(NativeDllAfterUnloadTriggerAttribute)))
93+
RegisterTriggerMethod(method, ref _customAfterUnloadTriggers);
9594
}
9695
}
9796
}

scripts/Editor/DllManipulatorEditor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ public class DllManipulatorEditor : Editor
6161
private bool _showTargetAssemblies = true;
6262
private string[] _allKnownAssemblies = null;
6363
private DateTime _lastKnownAssembliesRefreshTime;
64-
64+
65+
public static event Action RepaintAllEditors = delegate {};
66+
6567
public DllManipulatorEditor()
6668
{
6769
EditorApplication.pauseStateChanged += _ => Repaint();
6870
EditorApplication.playModeStateChanged += _ => Repaint();
71+
RepaintAllEditors += Repaint;
6972
}
7073

7174
public override void OnInspectorGUI()
@@ -346,10 +349,7 @@ public static void UnloadAll()
346349
[NativeDllAfterUnloadTrigger]
347350
public static void RepaintAll()
348351
{
349-
var editors = Resources.FindObjectsOfTypeAll<DllManipulatorEditor>();
350-
if(editors == null) return;
351-
foreach (var editor in editors)
352-
editor.Repaint();
352+
RepaintAllEditors.Invoke();
353353
}
354354
}
355355
}

scripts/Editor/DllManipulatorWindowEditor.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ static void Init()
1313
{
1414
window = GetWindow<DllManipulatorWindowEditor>();
1515
window.Show();
16-
}
17-
18-
[NativeDllLoadedTrigger]
19-
[NativeDllAfterUnloadTrigger]
20-
public static void RepaintAll()
21-
{
22-
if(window) window.Repaint();
16+
DllManipulatorEditor.RepaintAllEditors += window.Repaint;
2317
}
2418

2519
void OnGUI()

0 commit comments

Comments
 (0)