mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Resolve Application.isEditor once
This will prevent spamming of "Use isEditor in Awake" in debug builds
This commit is contained in:
1 parent
1b6537b2a1
commit
a882ef89b2
2 files changed
+10
-2
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user