Code/Graphics/GraphicsSettings.cs

Component that holds global graphics settings for the scene. It enforces a singleton Instance, logs a warning if multiple are created, and applies water reflection mode on start.

namespace AtmokineticAssets;

[Title( "Atmokinetic Assets - Graphics Settings" )]
[Category( "Atmokinetic Assets" )]
[Icon( "settings" )]

public sealed partial class GraphicsSettings : Component, Component.ExecuteInEditor
{
    /// <summary>
    /// The scene's GraphicsSettings. There should only ever be one.
    /// </summary>
    public static GraphicsSettings Instance { get; private set; }

    protected override void OnAwake()
    {
        if ( Instance.IsValid() && Instance != this )
            Log.Warning( $"Multiple GraphicsSettings components in the scene - {GameObject.Name} is replacing {Instance.GameObject.Name}" );

        Instance = this;
    }

    protected override void OnDestroy()
    {
        if ( Instance == this )
            Instance = null;
    }

    protected override void OnStart()
    {
        ApplyWaterReflectionModeDynamic();
    }

    protected override void OnUpdate()
    {

    }
}