首次提交
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ilumisoft.GraphicsControl
|
||||
{
|
||||
[System.Serializable, System.Flags]
|
||||
public enum FullScreenModeOptions
|
||||
{
|
||||
ExclusiveFullScreen = 1,
|
||||
FullScreenWindow = 2,
|
||||
MaximizedWindow = 4,
|
||||
Windowed = 8,
|
||||
Everything = 0b1111
|
||||
}
|
||||
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Graphics Control/Settings/Full Screen Mode Setting")]
|
||||
public class FullScreenModeSetting : MultiOptionGraphicSetting<FullScreenMode>
|
||||
{
|
||||
[SerializeField]
|
||||
FullScreenModeOptions EnabledOptions = FullScreenModeOptions.Everything;
|
||||
|
||||
public FullScreenMode DefaultOption = FullScreenMode.ExclusiveFullScreen;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
AddOptionIfEnabled(FullScreenMode.Windowed);
|
||||
AddOptionIfEnabled(FullScreenMode.FullScreenWindow);
|
||||
AddOptionIfEnabled(FullScreenMode.MaximizedWindow);
|
||||
AddOptionIfEnabled(FullScreenMode.ExclusiveFullScreen);
|
||||
|
||||
// Always add the default option if not already added
|
||||
if(!IsEnabled(DefaultOption))
|
||||
{
|
||||
AddOption(GetDisplayName(DefaultOption), DefaultOption);
|
||||
}
|
||||
|
||||
SelectOption(DefaultOption);
|
||||
}
|
||||
|
||||
bool IsEnabled(FullScreenMode fullScreenMode)
|
||||
{
|
||||
return fullScreenMode switch
|
||||
{
|
||||
FullScreenMode.ExclusiveFullScreen => EnabledOptions.HasFlag(FullScreenModeOptions.ExclusiveFullScreen),
|
||||
FullScreenMode.FullScreenWindow => EnabledOptions.HasFlag(FullScreenModeOptions.FullScreenWindow),
|
||||
FullScreenMode.MaximizedWindow => EnabledOptions.HasFlag(FullScreenModeOptions.MaximizedWindow),
|
||||
FullScreenMode.Windowed => EnabledOptions.HasFlag(FullScreenModeOptions.Windowed),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given option to the option table if it has been set in the EnabledOptions
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="option"></param>
|
||||
void AddOptionIfEnabled(FullScreenMode option)
|
||||
{
|
||||
if (IsEnabled(option))
|
||||
{
|
||||
AddOption(GetDisplayName(option), option);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display name the given <see cref="FullScreenMode"/>
|
||||
/// </summary>
|
||||
/// <param name="fullScreenMode"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
string GetDisplayName(FullScreenMode fullScreenMode) => fullScreenMode switch
|
||||
{
|
||||
FullScreenMode.ExclusiveFullScreen => "Exclusive Fullscreen",
|
||||
FullScreenMode.FullScreenWindow => "Full Screen Window",
|
||||
FullScreenMode.MaximizedWindow => "Maximized Window",
|
||||
FullScreenMode.Windowed => "Window",
|
||||
_ => throw new System.NotImplementedException(),
|
||||
};
|
||||
|
||||
public override string GetSettingName() => "Full Screen Mode";
|
||||
|
||||
public override void SaveSetting()
|
||||
{
|
||||
GraphicSettingsStorage.SetInt("Full Screen Mode", (int)GetSelectedOption());
|
||||
}
|
||||
|
||||
public override void LoadSetting()
|
||||
{
|
||||
int value = GraphicSettingsStorage.GetInt("Full Screen Mode", (int)DefaultOption);
|
||||
|
||||
SelectOption((FullScreenMode)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43e4b0176d7b9c8458e46f9587b50868
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 688fa00e4a40a034eacc71c7a11ff9d0, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9ec92119fc6ebe458677efe991f486b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ilumisoft.GraphicsControl
|
||||
{
|
||||
[AddComponentMenu("Graphics Control/Settings/Ambient Occlusion Setting")]
|
||||
[DisallowMultipleComponent()]
|
||||
public class AmbientOcclusionSetting : ToggleGraphicSetting
|
||||
{
|
||||
public override string GetSettingName() => "Ambient Occlusion";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faecca85295be1440be1629220477394
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 688fa00e4a40a034eacc71c7a11ff9d0, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ilumisoft.GraphicsControl
|
||||
{
|
||||
[AddComponentMenu("Graphics Control/Settings/Bloom Setting")]
|
||||
[DisallowMultipleComponent()]
|
||||
public class BloomSetting : ToggleGraphicSetting
|
||||
{
|
||||
public override string GetSettingName() => "Bloom";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d77ee60ff507582488de1b21409b4ffd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 688fa00e4a40a034eacc71c7a11ff9d0, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ilumisoft.GraphicsControl
|
||||
{
|
||||
[AddComponentMenu("Graphics Control/Settings/Chromatic Aberration Setting")]
|
||||
[DisallowMultipleComponent()]
|
||||
public class ChromaticAberrationSetting : ToggleGraphicSetting
|
||||
{
|
||||
public override string GetSettingName() => "Chromatic Aberration";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06578898b8ae5ba408a50bdc92f95b6a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 688fa00e4a40a034eacc71c7a11ff9d0, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ilumisoft.GraphicsControl
|
||||
{
|
||||
[AddComponentMenu("Graphics Control/Settings/Grain Setting")]
|
||||
[DisallowMultipleComponent()]
|
||||
public class GrainSetting : ToggleGraphicSetting
|
||||
{
|
||||
public override string GetSettingName() => "Grain";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a34ac59a2b342ac4d95043f9d43cd773
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 688fa00e4a40a034eacc71c7a11ff9d0, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ilumisoft.GraphicsControl
|
||||
{
|
||||
[AddComponentMenu("Graphics Control/Settings/Motion Blur Setting")]
|
||||
[DisallowMultipleComponent()]
|
||||
public class MotionBlurSetting : ToggleGraphicSetting
|
||||
{
|
||||
public override string GetSettingName() => "Motion Blur";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab1af6deb663e5047800769e92315fb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 688fa00e4a40a034eacc71c7a11ff9d0, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ilumisoft.GraphicsControl
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Graphics Control/Settings/Quality Setting")]
|
||||
public class QualitySetting : MultiOptionGraphicSetting<int>
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
var names = QualitySettings.names;
|
||||
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
{
|
||||
AddOption(names[i], i);
|
||||
}
|
||||
|
||||
SetIndex(QualitySettings.GetQualityLevel());
|
||||
}
|
||||
|
||||
public override string GetSettingName() => "Quality";
|
||||
|
||||
public override void SaveSetting()
|
||||
{
|
||||
GraphicSettingsStorage.SetInt(key: GetSettingName(), value: GetIndex());
|
||||
}
|
||||
|
||||
public override void LoadSetting()
|
||||
{
|
||||
// The key of the setting
|
||||
string key = GetSettingName();
|
||||
|
||||
// Default value used as a fallback option
|
||||
int defaultValue = QualitySettings.GetQualityLevel();
|
||||
|
||||
// Get the stored value
|
||||
int storedValue = GraphicSettingsStorage.GetInt(key, defaultValue);
|
||||
|
||||
// Apply the stored value
|
||||
SetIndex(storedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0db9cdd8379cfca4b8d2230daaacfd5d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 688fa00e4a40a034eacc71c7a11ff9d0, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ilumisoft.GraphicsControl
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Graphics Control/Settings/Resolution Setting")]
|
||||
public class ResolutionSetting : MultiOptionGraphicSetting<Resolution>
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
var supportedResolutions = Screen.resolutions;
|
||||
|
||||
foreach (var resolution in supportedResolutions)
|
||||
{
|
||||
AddOption($"{resolution.width}x{resolution.height}", resolution);
|
||||
}
|
||||
|
||||
SelectOption(r => AreEqual(r, Screen.currentResolution), defaultIndex: 0);
|
||||
}
|
||||
|
||||
public override string GetSettingName() => "Resolution";
|
||||
|
||||
public override void SaveSetting()
|
||||
{
|
||||
GraphicSettingsStorage.SetInt("Resolution_Width", GetSelectedOption().width);
|
||||
GraphicSettingsStorage.SetInt("Resolution_Height", GetSelectedOption().height);
|
||||
}
|
||||
|
||||
public override void LoadSetting()
|
||||
{
|
||||
var currentResolution = Screen.currentResolution;
|
||||
|
||||
Resolution resolution = new()
|
||||
{
|
||||
width = GraphicSettingsStorage.GetInt("Resolution_Width", currentResolution.width),
|
||||
height = GraphicSettingsStorage.GetInt("Resolution_Height", currentResolution.height)
|
||||
};
|
||||
|
||||
SelectOption(r => AreEqual(r, resolution), defaultIndex: 0);
|
||||
}
|
||||
|
||||
bool AreEqual(Resolution a, Resolution b)
|
||||
{
|
||||
return a.width == b.width && a.height == b.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 438c606e3c3e3b440bbc978d859f759b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 688fa00e4a40a034eacc71c7a11ff9d0, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ilumisoft.GraphicsControl
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Graphics Control/Settings/VSync Setting")]
|
||||
public class VSyncSetting : ToggleGraphicSetting
|
||||
{
|
||||
public override string GetSettingName() => "VSync";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f677a30b5f601d4aac04bd65aeb366a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 688fa00e4a40a034eacc71c7a11ff9d0, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user