浏览代码

Made a refactor of the used setting classes as follows:

- Logic is now split into sub components: Genera, Graphics, Audio and Input (currently empty as input system is wip)

- The settings system class can be used to get information from all sub components, a distributor

- Fixed an issue with Screen resolution not being correct when in windowed mode (Screen.currentResolution gives back desktop resolution when in windowed mode)

- Added Input UI elements which are placeholders for now, once the input system is done this can be populated like the other settings sub components
/main
Ayhan Sakarya 4 年前
当前提交
05abd3e9
共有 12 个文件被更改,包括 976 次插入337 次删除
  1. 668
      UOP1_Project/Assets/Scenes/Settings System.unity
  2. 21
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsPresetsScriptableObject.cs
  3. 246
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystem.cs
  4. 14
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsUIController.cs
  5. 44
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemAudioComponent.cs
  6. 11
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemAudioComponent.cs.meta
  7. 44
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemGeneralComponent.cs
  8. 11
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemGeneralComponent.cs.meta
  9. 208
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemGraphicsComponent.cs
  10. 11
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemGraphicsComponent.cs.meta
  11. 24
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemSubComponents.cs
  12. 11
      UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemSubComponents.cs.meta

668
UOP1_Project/Assets/Scenes/Settings System.unity


onValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 1447991545}
m_MethodName: OnChangeFullscreen
m_Mode: 0
m_Arguments:

m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 513
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 513
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 257
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 514
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 346016617}
m_CullTransparentMesh: 0
--- !u!1 &354004779
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 354004780}
- component: {fileID: 354004782}
- component: {fileID: 354004781}
m_Layer: 5
m_Name: Input Button Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &354004780
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 354004779}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1740413279}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &354004781
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 354004779}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Input
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4281479730
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 35
m_fontSizeBase: 35
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 1
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &354004782
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 354004779}
m_CullTransparentMesh: 0
--- !u!1 &369239345
GameObject:
m_ObjectHideFlags: 0

serializedVersion: 6
m_Component:
- component: {fileID: 419038884}
- component: {fileID: 419038885}
m_Layer: 5
m_Name: General
m_TagString: Untagged

m_IsActive: 1
m_IsActive: 0
--- !u!224 &419038884
RectTransform:
m_ObjectHideFlags: 0

m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &419038885
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 419038883}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5cbf3de30afb74cb39db3ba32a890fda, type: 3}
m_Name:
m_EditorClassIdentifier:
languageDropdown: {fileID: 439252345}
--- !u!1 &439252344
GameObject:
m_ObjectHideFlags: 0

m_OnValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 419038885}
m_MethodName: OnChangeLanguage
m_Mode: 0
m_Arguments:

m_Children:
- {fileID: 967335197}
m_Father: {fileID: 2104362800}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}

m_HandleRect: {fileID: 748921744}
m_Direction: 0
m_MinValue: 0
m_MaxValue: 1
m_WholeNumbers: 0
m_Value: 0.5
m_MaxValue: 100
m_WholeNumbers: 1
m_Value: 50
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 2006933597}
m_MethodName: OnChangeMusicVolume
m_Mode: 0
m_Arguments:

m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 1447991545}
m_MethodName: OnSaveGraphicsSettings
m_Mode: 1
m_Arguments:

m_AnchoredPosition: {x: -567, y: -753}
m_SizeDelta: {x: 300, y: 80}
m_Pivot: {x: 0.5, y: 1}
--- !u!1 &629685478
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 629685479}
m_Layer: 5
m_Name: Input
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &629685479
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 629685478}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2045321612}
m_Father: {fileID: 2104362800}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &640388293
GameObject:
m_ObjectHideFlags: 0

m_OnValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 1447991545}
m_MethodName: OnChangeShadowDistance
m_Mode: 0
m_Arguments:

m_OnValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 1447991545}
m_MethodName: OnChangeAnisotropicFiltering
m_Mode: 0
m_Arguments:

m_OnValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 1447991545}
m_MethodName: OnChangeShadowQuality
m_Mode: 0
m_Arguments:

m_OnValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 1447991545}
m_MethodName: OnChangeResolution
m_Mode: 0
m_Arguments:

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_HorizontalAlignment: 4
m_textAlignment: 260
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 513
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 516
m_HorizontalAlignment: 4
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 257
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_EditorClassIdentifier:
m_MoveRepeatDelay: 0.5
m_MoveRepeatRate: 0.1
m_ActionsAsset: {fileID: -944628639613478452, guid: 47a7bd10b734b954e95d4dbf166f5578,
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_PointAction: {fileID: 1054132383583890850, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_MoveAction: {fileID: -1680190386980627800, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_SubmitAction: {fileID: 2064916234097673511, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_CancelAction: {fileID: -1967631576421560919, guid: ca9f5fa95ffab41fb9a615ab714db018,
m_PointAction: {fileID: 0}
m_MoveAction: {fileID: 3255455418203087956, guid: 47a7bd10b734b954e95d4dbf166f5578,
m_LeftClickAction: {fileID: 8056856818456041789, guid: ca9f5fa95ffab41fb9a615ab714db018,
m_SubmitAction: {fileID: 0}
m_CancelAction: {fileID: 0}
m_LeftClickAction: {fileID: 0}
m_MiddleClickAction: {fileID: 0}
m_RightClickAction: {fileID: 0}
m_ScrollWheelAction: {fileID: 0}
m_TrackedDevicePositionAction: {fileID: 0}
m_TrackedDeviceOrientationAction: {fileID: 0}
m_MiddleClickAction: {fileID: 3279352641294131588, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_RightClickAction: {fileID: 3837173908680883260, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_ScrollWheelAction: {fileID: 4502412055082496612, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_TrackedDevicePositionAction: {fileID: 4754684134866288074, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_TrackedDeviceOrientationAction: {fileID: 1025543830046995696, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0
--- !u!114 &1134079589

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 513
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_OnValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 1447991545}
m_MethodName: OnChangeQualityPreset
m_Mode: 0
m_Arguments:

m_Children:
- {fileID: 2078827068}
m_Father: {fileID: 2104362800}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}

m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 1447991545}
m_MethodName: OnCancelGraphicsSettings
m_Mode: 1
m_Arguments:

serializedVersion: 6
m_Component:
- component: {fileID: 1447991544}
- component: {fileID: 1447991545}
m_Layer: 5
m_Name: Graphics
m_TagString: Untagged

m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1447991545
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1447991543}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb22202e544f74ee4b52c6ab7035e5e2, type: 3}
m_Name:
m_EditorClassIdentifier:
resolutionsDropdown: {fileID: 884498919}
shadowQualityDropdown: {fileID: 758916854}
anisotropicFilteringDropdown: {fileID: 714527125}
graphicsPresetsDropdown: {fileID: 1199992350}
antiAliasingSlider: {fileID: 2039261687}
shadowDistanceSlider: {fileID: 640388295}
fullscreenToggle: {fileID: 38928778}
antiAliasingText: {fileID: 1046367281}
shadowDistanceText: {fileID: 163589647}
settingsPresets: {fileID: 11400000, guid: 8cdf9b9e9fa3444209be445de7a2a6ac, type: 2}
--- !u!1 &1460917962
GameObject:
m_ObjectHideFlags: 0

m_Children:
- {fileID: 1722482440}
m_Father: {fileID: 2104362800}
m_RootOrder: 5
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}

m_HandleRect: {fileID: 317976170}
m_Direction: 0
m_MinValue: 0
m_MaxValue: 1
m_WholeNumbers: 0
m_Value: 0.5
m_MaxValue: 100
m_WholeNumbers: 1
m_Value: 50
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 2006933597}
m_MethodName: OnChangeSfxVolume
m_Mode: 0
m_Arguments:

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 516
m_HorizontalAlignment: 4
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_HorizontalAlignment: 4
m_textAlignment: 260
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 513
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1735917596}
m_CullTransparentMesh: 0
--- !u!1 &1740413278
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1740413279}
- component: {fileID: 1740413282}
- component: {fileID: 1740413281}
- component: {fileID: 1740413280}
m_Layer: 5
m_Name: Input Button
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1740413279
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1740413278}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 354004780}
m_Father: {fileID: 2104362800}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 483, y: -50}
m_SizeDelta: {x: 300, y: 80}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &1740413280
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1740413278}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 1, g: 1, b: 1, a: 1}
m_DisabledColor: {r: 0.53786933, g: 0.745283, b: 0.569909, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1740413281}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362804}
m_MethodName: OpenInputSettings
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &1740413281
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1740413278}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1740413282
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1740413278}
m_CullTransparentMesh: 0
--- !u!1 &1758935670
GameObject:
m_ObjectHideFlags: 0

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 516
m_HorizontalAlignment: 4
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 516
m_HorizontalAlignment: 4
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

serializedVersion: 6
m_Component:
- component: {fileID: 2006933595}
- component: {fileID: 2006933597}
m_Layer: 5
m_Name: Audio
m_TagString: Untagged

m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2006933597
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2006933594}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b4ddec376a8a84d5791648f98ca38df6, type: 3}
m_Name:
m_EditorClassIdentifier:
musicVolumeSlider: {fileID: 528347559}
sfxVolumeSlider: {fileID: 1546186709}
--- !u!1 &2018086142
GameObject:
m_ObjectHideFlags: 0

m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 0
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2

m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 514
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0

m_OnValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2104362801}
- m_Target: {fileID: 1447991545}
m_MethodName: OnChangeAntialiasing
m_Mode: 0
m_Arguments:

m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!1 &2045321611
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2045321612}
- component: {fileID: 2045321614}
- component: {fileID: 2045321613}
m_Layer: 5
m_Name: TODO
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2045321612
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2045321611}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 629685479}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 198.56763, y: 87.6792}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2045321613
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2045321611}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: TODO
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4278190335
m_fontColor: {r: 1, g: 0, b: 0, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 102.8
m_fontSizeBase: 102.8
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 0
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 1
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &2045321614
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2045321611}
m_CullTransparentMesh: 0
--- !u!1 &2047527177
GameObject:
m_ObjectHideFlags: 0

- {fileID: 419038884}
- {fileID: 1447991544}
- {fileID: 2006933595}
- {fileID: 629685479}
- {fileID: 1740413279}
m_Father: {fileID: 192432982}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_Script: {fileID: 11500000, guid: f22d7dd090554473dafb70b86d96e108, type: 3}
m_Name:
m_EditorClassIdentifier:
resolutionsDropdown: {fileID: 884498919}
languageDropdown: {fileID: 439252345}
shadowQualityDropdown: {fileID: 758916854}
anisotropicFilteringDropdown: {fileID: 714527125}
qualityPresetsDropdown: {fileID: 1199992350}
antiAliasingSlider: {fileID: 2039261687}
shadowDistanceSlider: {fileID: 640388295}
musicVolumeSlider: {fileID: 528347559}
sfxVolumeSlider: {fileID: 1546186709}
antiAliasingText: {fileID: 1046367281}
shadowDistanceText: {fileID: 163589647}
settingsPresets: {fileID: 11400000, guid: 8cdf9b9e9fa3444209be445de7a2a6ac, type: 2}
generalComponent: {fileID: 419038885}
graphicsComponent: {fileID: 1447991545}
audioComponent: {fileID: 2006933597}
--- !u!114 &2104362802
MonoBehaviour:
m_ObjectHideFlags: 0

generalSettings: {fileID: 419038883}
graphicsSettings: {fileID: 1447991543}
audioSettings: {fileID: 2006933594}
inputSettings: {fileID: 629685478}
inputSettingsButton: {fileID: 1740413280}
saveGraphicsSettingsButton: {fileID: 543540057}
cancelGraphicsSettingsButton: {fileID: 1307352550}

21
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsPresetsScriptableObject.cs


[Serializable]
public struct AdvancedGraphics
{
public string name;
public GraphicsQualityLevel qualityLevel;
public ShadowQuality shadowQuality;
public AnisotropicFiltering anisotropicFiltering;
public int antiAliasing;

public string[] GetPresetNames()
public enum GraphicsQualityLevel
{
Low,
Middle,
High
}
public AdvancedGraphics GetPresetByQualityLevel(GraphicsQualityLevel level)
string[] presetNames = new string[presetList.Count];
for (int i = 0; i < presetList.Count; i++)
foreach (AdvancedGraphics preset in presetList)
presetNames[i] = presetList[i].name;
if (level == preset.qualityLevel)
{
return preset;
}
return presetNames;
return default;
}
}

246
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystem.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
using UnityEngine;
[SerializeField] TMP_Dropdown resolutionsDropdown;
[SerializeField] TMP_Dropdown languageDropdown;
[SerializeField] TMP_Dropdown shadowQualityDropdown;
[SerializeField] TMP_Dropdown anisotropicFilteringDropdown;
[SerializeField] TMP_Dropdown qualityPresetsDropdown;
[SerializeField] Slider antiAliasingSlider;
[SerializeField] Slider shadowDistanceSlider;
[SerializeField] Slider musicVolumeSlider;
[SerializeField] Slider sfxVolumeSlider;
[SerializeField] TextMeshProUGUI antiAliasingText;
[SerializeField] TextMeshProUGUI shadowDistanceText;
[SerializeField] SettingsPresetsScriptableObject settingsPresets;
public bool FullScreen { get; private set; }
public float MusicVolume { get; private set; }
public float SfxVolume { get; private set; }
public LanguageSetting Language { get; private set; }
SettingsPresetsScriptableObject.AdvancedGraphics currentAdvancedGraphics, previousAdvancedGraphics;
int currentQualityLevel, previousQualityLevel; //-1 is custom
public enum LanguageSetting
{
English,
German,
//TODO: which languages are going to be supported?
}
void Start()
{
//TODO: Load previous settings data via save/load interface
resolutionsDropdown.AddOptions(GetResolutionsDropdownData());
languageDropdown.AddOptions(GetDropdownData(Enum.GetNames(typeof(LanguageSetting))));
qualityPresetsDropdown.AddOptions(GetDropdownData(settingsPresets.GetPresetNames(), "Custom"));
foreach (string s in QualitySettings.names)
{
Debug.Log(s);
}
anisotropicFilteringDropdown.AddOptions(GetDropdownData(Enum.GetNames(typeof(AnisotropicFiltering))));
shadowQualityDropdown.AddOptions(GetDropdownData(Enum.GetNames(typeof(ShadowQuality))));
LoadCurrentSettings();
}
void LoadCurrentSettings()
{
int resolutionIndex = 0;
//TODO: load previous resolution setting. If not existing find current resolution index
for (int i = 0; i < Screen.resolutions.Length; i++)
{
if (Screen.currentResolution.ToString() == Screen.resolutions[i].ToString())
{
resolutionIndex = i;
}
}
resolutionsDropdown.SetValueWithoutNotify(resolutionIndex);
//TODO: load quality level from previous session. If custom, set qualityPresetsDropdown to custom. Option "custom" is added in GetQualityPresetsDropdownData()
previousQualityLevel = currentQualityLevel;
currentAdvancedGraphics = settingsPresets.presetList[currentQualityLevel]; //Set to lowest preset initially
previousAdvancedGraphics = currentAdvancedGraphics;
qualityPresetsDropdown.SetValueWithoutNotify(currentAdvancedGraphics.custom ? qualityPresetsDropdown.options.Count-1 : currentQualityLevel);
UpdateAdvancedGraphicsUI();
//TODO: load previous language setting
Language = LanguageSetting.English;
languageDropdown.SetValueWithoutNotify((int) Language);
//TODO: load previous fullscreen setting
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
//TODO: load previous music volume setting
MusicVolume = 0.5f;
musicVolumeSlider.SetValueWithoutNotify(MusicVolume);
//TODO: load previous sfx volume setting
SfxVolume = 0.5f;
sfxVolumeSlider.SetValueWithoutNotify(SfxVolume);
}
void SelectGraphicsPreset(int level)
{
QualitySettings.SetQualityLevel(0, true);
UpdateAdvancedGraphicsUI();
}
void UpdateAdvancedGraphicsUI()
{
anisotropicFilteringDropdown.SetValueWithoutNotify((int) currentAdvancedGraphics.anisotropicFiltering);
antiAliasingSlider.SetValueWithoutNotify(currentAdvancedGraphics.antiAliasing);
shadowDistanceSlider.SetValueWithoutNotify(currentAdvancedGraphics.shadowDistance);
shadowQualityDropdown.SetValueWithoutNotify((int) currentAdvancedGraphics.shadowQuality);
shadowDistanceText.text = currentAdvancedGraphics.shadowDistance.ToString();
antiAliasingText.text = currentAdvancedGraphics.antiAliasing.ToString();
qualityPresetsDropdown.SetValueWithoutNotify(currentAdvancedGraphics.custom ? qualityPresetsDropdown.options.Count-1 : currentQualityLevel);
}
List<TMP_Dropdown.OptionData> GetResolutionsDropdownData()
{
List<TMP_Dropdown.OptionData> options = new List<TMP_Dropdown.OptionData>();
for (int i = 0; i < Screen.resolutions.Length; i++)
{
options.Add(new TMP_Dropdown.OptionData(Screen.resolutions[i].ToString()));
}
return options;
}
List<TMP_Dropdown.OptionData> GetDropdownData(string[] optionNames, params string[] customOptions)
{
List<TMP_Dropdown.OptionData> options = new List<TMP_Dropdown.OptionData>();
foreach (string option in optionNames)
{
options.Add(new TMP_Dropdown.OptionData(option));
}
foreach (string option in customOptions)
{
options.Add(new TMP_Dropdown.OptionData(option));
}
return options;
}
#region GENERAL SETTINGS
public void OnChangeLanguage(int languageIndex)
{
Language = (LanguageSetting) languageIndex;
Debug.Log("Language set to: " + Language);
}
#endregion
#region GRAPHICS SETTINGS
public void OnChangeFullscreen(bool fullScreen)
{
Screen.fullScreenMode = fullScreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.Windowed;
}
public void OnChangeResolution(int resolutionIndex)
{
Resolution newResolution = Screen.resolutions[resolutionIndex];
Screen.SetResolution(newResolution.width, newResolution.height, Screen.fullScreenMode);
}
public void OnChangeAnisotropicFiltering(int anisoLevel)
{
currentAdvancedGraphics.anisotropicFiltering = (AnisotropicFiltering) anisoLevel;
currentAdvancedGraphics.custom = true;
UpdateAdvancedGraphicsUI();
}
[SerializeField] SettingsSystemGeneralComponent generalComponent;
[SerializeField] SettingsSystemGraphicsComponent graphicsComponent;
[SerializeField] SettingsSystemAudioComponent audioComponent;
public void OnChangeAntialiasing(float value)
{
currentAdvancedGraphics.antiAliasing = (int) value;
currentAdvancedGraphics.custom = true;
UpdateAdvancedGraphicsUI();
}
public SettingsSystemGeneralComponent.LanguageSetting Language => generalComponent.Language;
public bool FullScreen => graphicsComponent.FullScreen;
public float MusicVolume => audioComponent.MusicVolume;
public float SfxVolume => audioComponent.SfxVolume;
public void OnChangeShadowDistance(float shadowDistanceValue)
{
//TODO: configure min max value in slider
currentAdvancedGraphics.shadowDistance = shadowDistanceValue;
currentAdvancedGraphics.custom = true;
UpdateAdvancedGraphicsUI();
}
public void OnChangeShadowQuality(int level)
{
currentAdvancedGraphics.shadowQuality = (ShadowQuality) level;
currentAdvancedGraphics.custom = true;
UpdateAdvancedGraphicsUI();
}
public void OnChangeQualityPreset(int level)
{
if (level >= settingsPresets.presetList.Count)
{
//Custom level chosen
currentAdvancedGraphics.custom = true;
}
else
{
currentAdvancedGraphics = settingsPresets.presetList[level];
}
currentQualityLevel = level;
UpdateAdvancedGraphicsUI();
}
#endregion
#region AUDIO SETTINGS
//TODO: clamp volume to [0, 1] or [0, 100]? Change Slider min max value in editor depending on use case
public void OnChangeMusicVolume(float volume)
{
MusicVolume = Mathf.Clamp(volume, 0.0f, 1.0f);
}
//TODO: clamp volume to [0, 1] or [0, 100]? Change Slider min max value in editor depending on use case
public void OnChangeSfxVolume(float volume)
{
SfxVolume = Mathf.Clamp(volume, 0.0f, 1.0f);
}
#endregion
public void OnSaveGraphicsSettings()
{
QualitySettings.anisotropicFiltering = currentAdvancedGraphics.anisotropicFiltering;
QualitySettings.antiAliasing = currentAdvancedGraphics.antiAliasing;
QualitySettings.shadowDistance = currentAdvancedGraphics.shadowDistance;
QualitySettings.shadows = currentAdvancedGraphics.shadowQuality;
previousAdvancedGraphics = currentAdvancedGraphics;
previousQualityLevel = currentQualityLevel;
Debug.Log("Antialiasing: " + QualitySettings.antiAliasing);
Debug.Log("Anisotropic Filtering: " + QualitySettings.anisotropicFiltering);
Debug.Log("Shadow Distance: " + QualitySettings.shadowDistance);
Debug.Log("Shadow Quality: " + QualitySettings.shadows);
}
public void OnCancelGraphicsSettings()
{
currentAdvancedGraphics = previousAdvancedGraphics;
currentQualityLevel = previousQualityLevel;
QualitySettings.anisotropicFiltering = currentAdvancedGraphics.anisotropicFiltering;
QualitySettings.antiAliasing = currentAdvancedGraphics.antiAliasing;
QualitySettings.shadowDistance = currentAdvancedGraphics.shadowDistance;
QualitySettings.shadows = currentAdvancedGraphics.shadowQuality;
UpdateAdvancedGraphicsUI();
}
}

14
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsUIController.cs


public class SettingsUIController : MonoBehaviour
{
[SerializeField] GameObject generalSettings, graphicsSettings, audioSettings;
[SerializeField] Button generalSettingsButton, graphicsSettingsButton, audioSettingsButton, saveGraphicsSettingsButton, cancelGraphicsSettingsButton;
[SerializeField] GameObject generalSettings, graphicsSettings, audioSettings, inputSettings;
[SerializeField] Button generalSettingsButton, graphicsSettingsButton, audioSettingsButton, inputSettingsButton, saveGraphicsSettingsButton, cancelGraphicsSettingsButton;
Audio
Audio,
Input
}
public void OpenGeneralSettings()

OpenSetting(SettingsType.Audio);
}
public void OpenInputSettings()
{
OpenSetting(SettingsType.Input);
}
public void OnSaveGraphicsSettings()
{
saveGraphicsSettingsButton.interactable = false;

generalSettings.SetActive(settingType == SettingsType.General);
graphicsSettings.SetActive((settingType == SettingsType.Graphics));
audioSettings.SetActive(settingType == SettingsType.Audio);
inputSettings.SetActive(settingType == SettingsType.Input);
inputSettingsButton.interactable = settingType != SettingsType.Input;
}
}

44
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemAudioComponent.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SettingsSystemAudioComponent : SettingsSystemSubComponents
{
[SerializeField] Slider musicVolumeSlider;
[SerializeField] Slider sfxVolumeSlider;
public float MusicVolume { get; private set; }
public float SfxVolume { get; private set; }
void Start()
{
Setup();
}
protected override void Setup()
{
//TODO: load previous music volume setting
MusicVolume = 50f;
musicVolumeSlider.SetValueWithoutNotify(MusicVolume);
//TODO: load previous sfx volume setting
SfxVolume = 50f;
sfxVolumeSlider.SetValueWithoutNotify(SfxVolume);
}
#region UI CALLBACKS
//TODO: clamp volume to [0, 1] or [0, 100]? Change Slider min max value in editor depending on use case
public void OnChangeMusicVolume(float volume)
{
MusicVolume = Mathf.Clamp(volume, 0.0f, 100.0f);
}
//TODO: clamp volume to [0, 1] or [0, 100]? Change Slider min max value in editor depending on use case
public void OnChangeSfxVolume(float volume)
{
SfxVolume = Mathf.Clamp(volume, 0.0f, 100.0f);
}
#endregion
}

11
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemAudioComponent.cs.meta


fileFormatVersion: 2
guid: b4ddec376a8a84d5791648f98ca38df6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

44
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemGeneralComponent.cs


using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class SettingsSystemGeneralComponent : SettingsSystemSubComponents
{
[SerializeField] TMP_Dropdown languageDropdown;
SettingsSystem settingsSystem;
public LanguageSetting Language { get; private set; }
public enum LanguageSetting
{
English,
German,
//TODO: which languages are going to be supported?
}
void Start()
{
Setup();
}
protected override void Setup()
{
settingsSystem = transform.parent.GetComponent<SettingsSystem>();
languageDropdown.AddOptions(GetDropdownData(Enum.GetNames(typeof(LanguageSetting))));
//TODO: Load previous serialized session data via Load/Save class
Language = SettingsSystemGeneralComponent.LanguageSetting.English;
languageDropdown.SetValueWithoutNotify((int) Language);
}
#region UI CALLBACKS
public void OnChangeLanguage(int languageIndex)
{
Language = (LanguageSetting) languageIndex;
Debug.Log("Language set to: " + Language);
}
#endregion
}

11
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemGeneralComponent.cs.meta


fileFormatVersion: 2
guid: 5cbf3de30afb74cb39db3ba32a890fda
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

208
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemGraphicsComponent.cs


using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class SettingsSystemGraphicsComponent : SettingsSystemSubComponents
{
[SerializeField] TMP_Dropdown resolutionsDropdown;
[SerializeField] TMP_Dropdown shadowQualityDropdown;
[SerializeField] TMP_Dropdown anisotropicFilteringDropdown;
[SerializeField] TMP_Dropdown graphicsPresetsDropdown;
[SerializeField] Slider antiAliasingSlider;
[SerializeField] Slider shadowDistanceSlider;
[SerializeField] Toggle fullscreenToggle;
[SerializeField] TextMeshProUGUI antiAliasingText;
[SerializeField] TextMeshProUGUI shadowDistanceText;
[SerializeField] SettingsPresetsScriptableObject settingsPresets;
bool setupComplete;
//Advanced graphic settings
SettingsPresetsScriptableObject.AdvancedGraphics currentAdvancedGraphics, previousAdvancedGraphics;
int currentQualityIndex, previousQualityIndex;
//Fullscreen settings
public bool FullScreen { get; private set; }
bool previouslyInFullScreen;
//Resolution setting
Resolution currentResolution, previousResolution;
void OnEnable()
{
if (!setupComplete)
{
Setup();
}
}
protected override void Setup()
{
resolutionsDropdown.AddOptions(GetResolutionsDropdownData());
graphicsPresetsDropdown.AddOptions(GetDropdownData(Enum.GetNames(typeof(SettingsPresetsScriptableObject.GraphicsQualityLevel)), "Custom"));
anisotropicFilteringDropdown.AddOptions(GetDropdownData(Enum.GetNames(typeof(AnisotropicFiltering))));
shadowQualityDropdown.AddOptions(GetDropdownData(Enum.GetNames(typeof(ShadowQuality))));
//RESOLUTION
//TODO: apparently, unity keeps the resolution which was set in the last session. But there is no method to get this resolution in the next session
//TODO: because Screen.currentResolution in windowed mode gives back the resolution of the desktop, not the unity window resolution
currentResolution = Screen.resolutions[Screen.resolutions.Length - 1]; //Initially set highest possible resolution on device
previousResolution = currentResolution;
Screen.SetResolution(currentResolution.width, currentResolution.height, Screen.fullScreenMode, currentResolution.refreshRate);
SelectCurrentResolution();
//FULLSCREEN MODE
//TODO: load previous session fullscreen setting
FullScreen = Screen.fullScreenMode == FullScreenMode.ExclusiveFullScreen;
previouslyInFullScreen = FullScreen;
fullscreenToggle.SetIsOnWithoutNotify(FullScreen);
//QUALITY PRESET
//TODO: instead of hardcoding the level here, load data from previous session
currentQualityIndex = (int) SettingsPresetsScriptableObject.GraphicsQualityLevel.Low;
previousQualityIndex = currentQualityIndex;
currentAdvancedGraphics = settingsPresets.presetList[currentQualityIndex]; //Set to lowest preset initially
previousAdvancedGraphics = currentAdvancedGraphics;
graphicsPresetsDropdown.SetValueWithoutNotify(currentAdvancedGraphics.custom ? graphicsPresetsDropdown.options.Count-1 : currentQualityIndex);
UpdateUI();
setupComplete = true;
}
List<TMP_Dropdown.OptionData> GetResolutionsDropdownData()
{
List<TMP_Dropdown.OptionData> options = new List<TMP_Dropdown.OptionData>();
for (int i = 0; i < Screen.resolutions.Length; i++)
{
options.Add(new TMP_Dropdown.OptionData(Screen.resolutions[i].ToString()));
}
return options;
}
void UpdateUI()
{
anisotropicFilteringDropdown.SetValueWithoutNotify((int) currentAdvancedGraphics.anisotropicFiltering);
antiAliasingSlider.SetValueWithoutNotify(currentAdvancedGraphics.antiAliasing);
shadowDistanceSlider.SetValueWithoutNotify(currentAdvancedGraphics.shadowDistance);
shadowQualityDropdown.SetValueWithoutNotify((int) currentAdvancedGraphics.shadowQuality);
shadowDistanceText.text = currentAdvancedGraphics.shadowDistance.ToString();
antiAliasingText.text = currentAdvancedGraphics.antiAliasing.ToString();
fullscreenToggle.SetIsOnWithoutNotify(FullScreen);
graphicsPresetsDropdown.SetValueWithoutNotify(currentAdvancedGraphics.custom ? graphicsPresetsDropdown.options.Count-1 : currentQualityIndex);
}
#region UI CALLBACKS
public void OnChangeFullscreen(bool fullScreen)
{
Screen.fullScreenMode = fullScreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.Windowed;
FullScreen = fullScreen;
}
public void OnChangeResolution(int resolutionIndex)
{
Debug.Log("Index: " + resolutionIndex);
currentResolution = Screen.resolutions[resolutionIndex];
Screen.SetResolution(currentResolution.width, currentResolution.height, Screen.fullScreenMode, currentResolution.refreshRate);
}
public void OnChangeAnisotropicFiltering(int anisoLevel)
{
currentAdvancedGraphics.anisotropicFiltering = (AnisotropicFiltering) anisoLevel;
currentAdvancedGraphics.custom = true;
UpdateUI();
}
public void OnChangeAntialiasing(float value)
{
currentAdvancedGraphics.antiAliasing = (int) value;
currentAdvancedGraphics.custom = true;
UpdateUI();
}
public void OnChangeShadowDistance(float shadowDistanceValue)
{
//TODO: configure min max value in slider
currentAdvancedGraphics.shadowDistance = shadowDistanceValue;
currentAdvancedGraphics.custom = true;
UpdateUI();
}
public void OnChangeShadowQuality(int level)
{
currentAdvancedGraphics.shadowQuality = (ShadowQuality) level;
currentAdvancedGraphics.custom = true;
UpdateUI();
}
public void OnChangeQualityPreset(int level)
{
if (level >= settingsPresets.presetList.Count)
{
//Custom level chosen
currentAdvancedGraphics.custom = true;
}
else
{
currentAdvancedGraphics = settingsPresets.presetList[level];
}
currentQualityIndex = level;
UpdateUI();
}
#endregion
void SelectCurrentResolution()
{
int resolutionIndex = 0;
//TODO: is resolution persistent once it is set? Need to test in build
for (int i = 0; i < Screen.resolutions.Length; i++)
{
if (currentResolution.width == Screen.resolutions[i].width &&
currentResolution.height == Screen.resolutions[i].height &&
currentResolution.refreshRate == Screen.resolutions[i].refreshRate)
{
resolutionIndex = i;
}
}
resolutionsDropdown.SetValueWithoutNotify(resolutionIndex);
}
public void OnSaveGraphicsSettings()
{
QualitySettings.anisotropicFiltering = currentAdvancedGraphics.anisotropicFiltering;
QualitySettings.antiAliasing = currentAdvancedGraphics.antiAliasing;
QualitySettings.shadowDistance = currentAdvancedGraphics.shadowDistance;
QualitySettings.shadows = currentAdvancedGraphics.shadowQuality;
previousAdvancedGraphics = currentAdvancedGraphics;
previousQualityIndex = currentQualityIndex;
previousResolution = currentResolution;
previouslyInFullScreen = FullScreen;
Debug.Log("Saving resolution state: " + currentResolution);
Debug.Log(("Saving fullscreen mode state: " + previouslyInFullScreen));
}
public void OnCancelGraphicsSettings()
{
currentAdvancedGraphics = previousAdvancedGraphics;
currentQualityIndex = previousQualityIndex;
QualitySettings.anisotropicFiltering = currentAdvancedGraphics.anisotropicFiltering;
QualitySettings.antiAliasing = currentAdvancedGraphics.antiAliasing;
QualitySettings.shadowDistance = currentAdvancedGraphics.shadowDistance;
QualitySettings.shadows = currentAdvancedGraphics.shadowQuality;
Screen.SetResolution(previousResolution.width, previousResolution.height, previouslyInFullScreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.Windowed, previousResolution.refreshRate);
// It might be a good idea to wait for the end of frame here with a coroutine, because setResolution actually is executed at the end of the next frame
//TODO: Observe this for issues in future
currentResolution = previousResolution;
FullScreen = previouslyInFullScreen;
SelectCurrentResolution();
UpdateUI();
Debug.Log("New Resolution: " + previousResolution);
Debug.Log("New fullscreen mode: " + FullScreen);
}
}

11
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemGraphicsComponent.cs.meta


fileFormatVersion: 2
guid: bb22202e544f74ee4b52c6ab7035e5e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

24
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemSubComponents.cs


using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public abstract class SettingsSystemSubComponents : MonoBehaviour
{
protected List<TMP_Dropdown.OptionData> GetDropdownData(string[] optionNames, params string[] customOptions)
{
List<TMP_Dropdown.OptionData> options = new List<TMP_Dropdown.OptionData>();
foreach (string option in optionNames)
{
options.Add(new TMP_Dropdown.OptionData(option));
}
foreach (string option in customOptions)
{
options.Add(new TMP_Dropdown.OptionData(option));
}
return options;
}
protected abstract void Setup();
}

11
UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSystemSubComponents.cs.meta


fileFormatVersion: 2
guid: e7303151e63a7428a8ecef4430d922fc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存