Initialize fields in static constructor

This commit is contained in:
Joshua Thome 2022-07-23 18:27:35 -05:00
parent f3fc243868
commit e4d70343e7

View File

@ -8,8 +8,8 @@ namespace NewHorizons.Builder.StarSystem
{ {
public class SkyboxBuilder public class SkyboxBuilder
{ {
private static int _skyboxLayer = -1; private static readonly int _skyboxLayer = LayerMask.NameToLayer("Skybox");
private static Shader _unlitShader; private static readonly Shader _unlitShader = Shader.Find("Unlit/Texture");
[Obsolete] [Obsolete]
public static void Make(StarSystemConfig.SkyboxConfig info, IModBehaviour mod) public static void Make(StarSystemConfig.SkyboxConfig info, IModBehaviour mod)
@ -40,9 +40,6 @@ namespace NewHorizons.Builder.StarSystem
var frontTex = ImageUtilities.GetTexture(mod, module.frontPath); var frontTex = ImageUtilities.GetTexture(mod, module.frontPath);
var backTex = ImageUtilities.GetTexture(mod, module.backPath); var backTex = ImageUtilities.GetTexture(mod, module.backPath);
if (_skyboxLayer == -1) _skyboxLayer = LayerMask.NameToLayer("Skybox");
if (!_unlitShader) _unlitShader = Shader.Find("Unlit/Texture");
var mesh = BuildSkySphereFaceMesh(module.useCube ? 1 : 32); var mesh = BuildSkySphereFaceMesh(module.useCube ? 1 : 32);
var skySphere = new GameObject("Sky Sphere"); var skySphere = new GameObject("Sky Sphere");