Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions scripts/DllManipulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,16 @@ internal static void Initialize(int unityMainThreadId, string assetsPath)
if (Options.mockAllNativeFunctions || method.IsDefined(typeof(MockNativeDeclarationAttribute)) || method.DeclaringType.IsDefined(typeof(MockNativeDeclarationsAttribute)))
MockNativeFunction(method);
}
else if(method.IsDefined(typeof(NativeDllLoadedTriggerAttribute)))
else
{
RegisterTriggerMethod(method, ref _customLoadedTriggers);
}
else if (method.IsDefined(typeof(NativeDllBeforeUnloadTriggerAttribute)))
{
RegisterTriggerMethod(method, ref _customBeforeUnloadTriggers);
}
else if (method.IsDefined(typeof(NativeDllAfterUnloadTriggerAttribute)))
{
RegisterTriggerMethod(method, ref _customAfterUnloadTriggers);
if (method.IsDefined(typeof(NativeDllLoadedTriggerAttribute)))
RegisterTriggerMethod(method, ref _customLoadedTriggers);

if (method.IsDefined(typeof(NativeDllBeforeUnloadTriggerAttribute)))
RegisterTriggerMethod(method, ref _customBeforeUnloadTriggers);

if (method.IsDefined(typeof(NativeDllAfterUnloadTriggerAttribute)))
RegisterTriggerMethod(method, ref _customAfterUnloadTriggers);
}
}
}
Expand Down
17 changes: 16 additions & 1 deletion scripts/Editor/DllManipulatorEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ public class DllManipulatorEditor : Editor
private bool _showTargetAssemblies = true;
private string[] _allKnownAssemblies = null;
private DateTime _lastKnownAssembliesRefreshTime;


public static event Action RepaintAllEditors = delegate {};

public DllManipulatorEditor()
{
EditorApplication.pauseStateChanged += _ => Repaint();
EditorApplication.playModeStateChanged += _ => Repaint();
RepaintAllEditors += Repaint;
}

public override void OnInspectorGUI()
Expand Down Expand Up @@ -139,6 +142,11 @@ public override void OnInspectorGUI()
var time = t.InitializationTime.Value;
EditorGUILayout.LabelField($"Initialized in: {(int)time.TotalSeconds}.{time.Milliseconds.ToString("D3")}s");
}

if (GUI.changed)
{
EditorUtility.SetDirty(target);
}
Comment thread
rogerbarton marked this conversation as resolved.
}

private void DrawUsedDlls(IList<NativeDllInfo> usedDlls)
Expand Down Expand Up @@ -333,5 +341,12 @@ public static void UnloadAll()
{
DllManipulator.UnloadAll();
}

[NativeDllLoadedTrigger]
[NativeDllAfterUnloadTrigger]
public static void RepaintAll()
{
RepaintAllEditors.Invoke();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's usually safer to handle null case with events (which can be done simply by putting ? before the dot). In this case you initialize the event, however I'm not sure if adding and removing an listener doesn't reset it back to null. Either or, it's better to be safe.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed however as the event is initialized with the default delegate it will never be null. https://stackoverflow.com/q/170907/9295437
Ill add it anyways...

}
}
}
5 changes: 4 additions & 1 deletion scripts/Editor/DllManipulatorWindowEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ namespace UnityNativeTool.Internal
{
public class DllManipulatorWindowEditor : EditorWindow
{
private static EditorWindow window;

[MenuItem("Window/Dll manipulator")]
static void Init()
{
var window = GetWindow<DllManipulatorWindowEditor>();
window = GetWindow<DllManipulatorWindowEditor>();
window.Show();
DllManipulatorEditor.RepaintAllEditors += window.Repaint;
}

void OnGUI()
Expand Down