New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add upm support #14
Add upm support #14
Changes from 9 commits
b6fbd98
97e04d8
4ff8168
4c3d948
00cc2ce
a5fd455
042c4aa
06abb19
f93f3c5
83b3751
a2a212c
bc1a749
8e1d0e3
f4bb9dc
6ca1ba0
e64dd99
b5d22b2
e737ee3
24ce6c5
6ed69a9
7d397ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
*.meta | ||
scripts/LICENSE.txt | ||
*.sln | ||
.vs | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "com.testpackage.unity-native-tool", | ||
"displayName": "Unity Native Tool", | ||
"version": "0.0.1", | ||
"unity": "2018.1", | ||
"description": "Tool for unloading native DLLs in the editor", | ||
"keywords": [ | ||
"native", | ||
"c++", | ||
"dll" | ||
], | ||
"category": "Unity", | ||
"type": "tool", | ||
"author": { | ||
"name": "John Doe", | ||
"email": "john.doe@example.com", | ||
"url": "https://github.com/mcpiroman/UnityNativeTool/" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:mcpiroman/UnityNativeTool.git", | ||
"revision": "6c6b17c36b33c72754d0bf2ee7e7236a68e10665" | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,18 @@ public partial class DllManipulator | |
public const string DLL_PATH_PATTERN_ASSETS_MACRO = "{assets}"; | ||
public const string DLL_PATH_PATTERN_PROJECT_MACRO = "{proj}"; | ||
private const string CRASH_FILE_NAME_PREFIX = "unityNativeCrash_"; | ||
public static readonly string[] DEFAULT_ASSEMBLY_NAMES = {"Assembly-CSharp" | ||
#if UNITY_EDITOR | ||
, "Assembly-CSharp-Editor" | ||
#endif | ||
}; | ||
public static readonly string[] INTERNAL_ASSEMBLY_NAMES = {"MCpiroman.UnityNativeTool" | ||
rogerbarton marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#if UNITY_EDITOR | ||
, "MCpiroman.UnityNativeTool.Editor" | ||
#endif | ||
}; | ||
public static readonly string[] IGNORED_ASSEMBLY_PREFIXES = { "UnityEngine.", "UnityEditor.", "Unity.", "com.unity.", "Mono." , "nunit."}; | ||
|
||
|
||
public static DllManipulatorOptions Options { get; set; } | ||
private static int _unityMainThreadId; | ||
|
@@ -47,20 +59,18 @@ internal static void Initialize(int unityMainThreadId, string assetsPath) | |
|
||
LowLevelPluginManager.ResetStubPlugin(); | ||
|
||
Assembly[] assemblies; | ||
if (Options.assemblyPaths.Length == 0) | ||
IEnumerable<string> assemblyPathsTemp = Options.assemblyNames; | ||
if (!assemblyPathsTemp.Any()) | ||
assemblyPathsTemp = DEFAULT_ASSEMBLY_NAMES; | ||
|
||
assemblyPathsTemp = assemblyPathsTemp.Concat(INTERNAL_ASSEMBLY_NAMES); | ||
|
||
var allAssemblies = AppDomain.CurrentDomain.GetAssemblies(); | ||
var assemblies = allAssemblies.Where(a => !a.IsDynamic && assemblyPathsTemp.Any(p => p == Path.ChangeExtension(a.ManifestModule.Name, null))).ToArray(); | ||
rogerbarton marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var missingAssemblies = assemblyPathsTemp.Except(assemblies.Select(a => Path.ChangeExtension(a.ManifestModule.Name, null))); | ||
foreach (var assembly in missingAssemblies) | ||
{ | ||
assemblies = new[] { Assembly.GetExecutingAssembly() }; | ||
} | ||
else | ||
{ | ||
var allAssemblies = AppDomain.CurrentDomain.GetAssemblies(); | ||
assemblies = allAssemblies.Where(a => !a.IsDynamic && Options.assemblyPaths.Any(p => p == PathUtils.NormallizeSystemAssemblyPath(a.Location))).ToArray(); | ||
var missingAssemblies = Options.assemblyPaths.Except(assemblies.Select(a => PathUtils.NormallizeSystemAssemblyPath(a.Location))); | ||
foreach (var assemblyPath in missingAssemblies) | ||
{ | ||
Debug.LogError($"Could not find assembly at path {assemblyPath}"); | ||
} | ||
Debug.LogError($"Could not find assembly: {assembly}"); | ||
} | ||
|
||
foreach (var assembly in assemblies) | ||
|
@@ -608,34 +618,34 @@ private static void WriteNativeCrashLog(NativeFunction nativeFunction, object[] | |
|
||
private static IntPtr SysLoadDll(string filepath) | ||
{ | ||
#if UNITY_STANDALONE_WIN | ||
return PInvokes_Windows.LoadLibrary(filepath); | ||
#elif UNITY_STANDALONE_LINUX | ||
#if UNITY_STANDALONE_LINUX | ||
return PInvokes_Linux.dlopen(filepath, (int)Options.posixDlopenFlags); | ||
#elif UNITY_STANDALONE_OSX | ||
return PInvokes_Osx.dlopen(filepath, (int)Options.posixDlopenFlags); | ||
#else // UNITY_STANDALONE_WIN | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the way it was somehow bad? I understand the addition of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I though it might be useful in some cases as there's quite a lot of platforms. But then it probably makes most sense to leave it as |
||
return PInvokes_Windows.LoadLibrary(filepath); | ||
#endif | ||
} | ||
|
||
private static bool SysUnloadDll(IntPtr libHandle) | ||
{ | ||
#if UNITY_STANDALONE_WIN | ||
return PInvokes_Windows.FreeLibrary(libHandle); | ||
#elif UNITY_STANDALONE_LINUX | ||
#if UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX | ||
return PInvokes_Linux.dlclose(libHandle) == 0; | ||
#elif UNITY_STANDALONE_OSX | ||
#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX | ||
return PInvokes_Osx.dlclose(libHandle) == 0; | ||
#else // UNITY_STANDALONE_WIN | ||
return PInvokes_Windows.FreeLibrary(libHandle); | ||
#endif | ||
} | ||
|
||
private static IntPtr SysGetDllProcAddress(IntPtr libHandle, string symbol) | ||
{ | ||
#if UNITY_STANDALONE_WIN | ||
return PInvokes_Windows.GetProcAddress(libHandle, symbol); | ||
#elif UNITY_STANDALONE_LINUX | ||
#if UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX | ||
return PInvokes_Linux.dlsym(libHandle, symbol); | ||
#elif UNITY_STANDALONE_OSX | ||
#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX | ||
return PInvokes_Osx.dlsym(libHandle, symbol); | ||
#else // UNITY_STANDALONE_WIN | ||
return PInvokes_Windows.GetProcAddress(libHandle, symbol); | ||
#endif | ||
} | ||
} | ||
|
@@ -644,7 +654,7 @@ private static IntPtr SysGetDllProcAddress(IntPtr libHandle, string symbol) | |
public class DllManipulatorOptions | ||
{ | ||
public string dllPathPattern; | ||
public string[] assemblyPaths; //empty means only executing assembly | ||
public List<string> assemblyNames; // empty means only default assemblies | ||
public DllLoadingMode loadingMode; | ||
public PosixDlopenFlags posixDlopenFlags; | ||
public bool threadSafe; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly, that's not my name :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nor an email
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where can I find them? they're not in your public profile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can live without that unless that's somehow mandatory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove the
author
field if you want it to stay anonymous? (fyi John Doe is just a placeholder name)