mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2024-12-29 12:21:25 +00:00
27 lines
870 B
C#
27 lines
870 B
C#
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using Mono.Cecil;
|
|
|
|
namespace Mirror.Weaver
|
|
{
|
|
static class Helpers
|
|
{
|
|
// This code is taken from SerializationWeaver
|
|
public static string UnityEngineDllDirectoryName()
|
|
{
|
|
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
|
|
return directoryName?.Replace(@"file:\", "");
|
|
}
|
|
|
|
public static bool IsEditorAssembly(AssemblyDefinition currentAssembly)
|
|
{
|
|
// we want to add the [InitializeOnLoad] attribute if it's available
|
|
// -> usually either 'UnityEditor' or 'UnityEditor.CoreModule'
|
|
return currentAssembly.MainModule.AssemblyReferences.Any(assemblyReference =>
|
|
assemblyReference.Name.StartsWith(nameof(UnityEditor))
|
|
);
|
|
}
|
|
}
|
|
}
|