Resolve Application.isEditor once

This will prevent spamming of "Use isEditor in Awake" in debug builds
This commit is contained in:
ghorsington committed 2021-03-21 20:26:00 +02:00
1 parent 1b6537b2a1
commit a882ef89b2
2 files changed
+10 -2

No files matched your search

+8
View File
@@ -45,6 +45,14 @@ namespace BepInEx.Bootstrap
[MethodImpl(MethodImplOptions.NoInlining)]
get => SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null;
}
// Check above for NoInlining reasoning
private static bool? isEditor;
internal static bool IsEditor
{
[MethodImpl(MethodImplOptions.NoInlining)]
get => isEditor ?? (isEditor = Application.isEditor) ?? false;
}
/// <summary>
/// List of all <see cref="BepInPlugin"/> loaded via the chainloader.
+2 -2
View File
@@ -36,7 +36,7 @@ namespace BepInEx
if(metadata == null)
throw new InvalidOperationException("Can't create an instance of " + GetType().FullName + " because it inherits from BaseUnityPlugin and the BepInPlugin attribute is missing.");
if (!Application.isEditor && Chainloader.PluginInfos.TryGetValue(metadata.GUID, out var info))
if (!Chainloader.IsEditor && Chainloader.PluginInfos.TryGetValue(metadata.GUID, out var info))
Info = info;
else
{
@@ -52,7 +52,7 @@ namespace BepInEx
Logger = Logging.Logger.CreateLogSource(metadata.Name);
string configRoot = Application.isEditor ? "." : Paths.ConfigPath;
string configRoot = Chainloader.IsEditor ? "." : Paths.ConfigPath;
Config = new ConfigFile(Utility.CombinePaths(configRoot, metadata.GUID + ".cfg"), false, metadata);
}
}