added graphics adjustment

This commit is contained in:
cyndrdev 2021-03-08 16:26:33 +00:00
parent 1d06cf5fb4
commit aa9526268c
28 changed files with 2082 additions and 97 deletions

File diff suppressed because one or more lines are too long

View File

@ -123,6 +123,51 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &704141725
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 704141726}
- component: {fileID: 704141727}
m_Layer: 0
m_Name: GraphicsSettings
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &704141726
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 704141725}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 953.24054, y: 546.3486, z: 366.31305}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &704141727
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 704141725}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e7c693bbffe7e0c4893681d7fd77cebb, type: 3}
m_Name:
m_EditorClassIdentifier:
_resolutionPlayerPref: {fileID: 11400000, guid: f8b98b846bbb94d41816fb15ff2bc84a, type: 2}
_fullscreenPlayerPref: {fileID: 11400000, guid: 3353af29005aa5b47873bb47d680a552, type: 2}
--- !u!1 &1029423380
GameObject:
m_ObjectHideFlags: 0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,85 @@
using System.Collections.Generic;
using UnityEngine;
public class GraphicsSettings : MonoBehaviour
{
private static Resolution[] _resolutions;
public static Resolution[] RESOLUTIONS
{
get
{
if ( _resolutions != null )
{
return _resolutions;
}
var resList = new List<Resolution>();
Resolution last = new Resolution();
foreach (var res in Screen.resolutions)
{
if ( res.height != last.height || res.height != last.height )
{
resList.Add(res);
last = res;
}
}
_resolutions = resList.ToArray();
return _resolutions;
}
}
private Resolution _currentResolution;
private FullScreenMode _fullscreenMode;
[SerializeField]
private PlayerPrefValue _resolutionPlayerPref;
[SerializeField]
private PlayerPrefValue _fullscreenPlayerPref;
private const FullScreenMode FULLSCREEN = FullScreenMode.FullScreenWindow;
private const FullScreenMode WINDOWED = FullScreenMode.Windowed;
private void Awake()
{
_currentResolution = RESOLUTIONS[ _resolutionPlayerPref.GetInt( RESOLUTIONS.Length - 1 ) ];
_fullscreenMode
= ( _fullscreenPlayerPref.GetInt( 1 ) > 0 )
? FULLSCREEN
: WINDOWED;
UpdateGraphics();
_resolutionPlayerPref.OnIntSet.AddListener(SetResolution);
_fullscreenPlayerPref.OnIntSet.AddListener( ( value ) => { SetFullscreen( value > 0 ); } );
}
private void SetResolution( int value )
{
_currentResolution = RESOLUTIONS[ value ];
UpdateGraphics();
}
private void SetFullscreen( bool value )
{
_fullscreenMode
= value
? FULLSCREEN
: WINDOWED;
UpdateGraphics();
}
private void UpdateGraphics()
{
Screen.SetResolution(
_currentResolution.width,
_currentResolution.height,
_fullscreenMode
);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e7c693bbffe7e0c4893681d7fd77cebb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,24 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(TMP_Dropdown))]
public class PlayerPrefDropdown : MonoBehaviour
{
private TMP_Dropdown _dropdown;
[SerializeField]
private PlayerPrefValue _playerPref;
private void Awake()
{
_dropdown = GetComponent<TMP_Dropdown>();
_dropdown.onValueChanged.AddListener( _playerPref.SetInt );
}
private void OnEnable()
{
int value = _playerPref.GetInt();
_dropdown.SetValueWithoutNotify( value );
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1fb9657377dda4c489cc17830675d184
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,18 +1,26 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Slider))]
public class PlayerPrefSlider : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
private Slider _slider;
[SerializeField]
private PlayerPrefValue _playerPref;
private void Awake()
{
_slider = GetComponent<Slider>();
_slider.onValueChanged.AddListener( _playerPref.SetFloat );
}
// Update is called once per frame
void Update()
private void OnEnable()
{
float value = _playerPref.GetFloat();
_slider.SetValueWithoutNotify( value );
}
}

View File

@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Toggle))]
public class PlayerPrefToggle : MonoBehaviour
{
private Toggle _toggle;
[SerializeField]
private PlayerPrefValue _playerPref;
[SerializeField]
private bool _defaultValue;
private void Awake()
{
_toggle = GetComponent<Toggle>();
_toggle.onValueChanged.AddListener( ( ticked ) => _playerPref.SetInt( ticked ? 1 : 0 ) );
}
private void OnEnable()
{
bool value = _playerPref.HasValue ? _playerPref.GetInt() > 0 : _defaultValue;
_toggle.isOn = value;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 823e8f97eec05b7418446c9e71d4238a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
[CreateAssetMenu(fileName = "PPValue.asset", menuName = "kernelpanic/PlayerPrefValue")]
[CreateAssetMenu(fileName = "PPValue.asset", menuName = "KernelPanic/PlayerPrefValue")]
public class PlayerPrefValue : ScriptableObject
{
[SerializeField]

View File

@ -0,0 +1,32 @@
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(TMP_Dropdown))]
public class ResolutionPicker : MonoBehaviour
{
private void Awake()
{
var dropdown = GetComponent<TMP_Dropdown>();
var resolutions = Screen.resolutions;
dropdown.options.Clear();
var options = new List<TMP_Dropdown.OptionData>();
foreach (var res in GraphicsSettings.RESOLUTIONS)
{
var data = new TMP_Dropdown.OptionData
{
image = null,
text = $"{res.width} x {res.height}"
};
options.Add(data);
}
dropdown.AddOptions( options );
dropdown.value = resolutions.Length - 1;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b50e29b5c808bbf4e93db5f8734f5d73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b718b1225e435be4bb025a1d07b6e879, type: 3}
m_Name: FullscreenPPV
m_EditorClassIdentifier:
KeyName: IsFullscreen

View File

@ -1,9 +1,8 @@
fileFormatVersion: 2
guid: a9b7aec0dbd482f489b727b6c3ab3fd3
labels:
- FMOD
DefaultImporter:
guid: 3353af29005aa5b47873bb47d680a552
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b718b1225e435be4bb025a1d07b6e879, type: 3}
m_Name: ResolutionPPV
m_EditorClassIdentifier:
KeyName: Resolution

View File

@ -1,9 +1,8 @@
fileFormatVersion: 2
guid: 90356c5beb272664687199ea3e14fa86
labels:
- FMOD
DefaultImporter:
guid: f8b98b846bbb94d41816fb15ff2bc84a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Binary file not shown.

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: f6b5fef480e45f3458dbe489b0583f75
labels:
- FMOD
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

BIN
game/Assets/StreamingAssets/Master.bank (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
game/Assets/StreamingAssets/Music.bank (Stored with Git LFS)

Binary file not shown.

BIN
game/Assets/StreamingAssets/SFX.bank (Stored with Git LFS)

Binary file not shown.

BIN
game/Assets/StreamingAssets/VO.bank (Stored with Git LFS)

Binary file not shown.

BIN
game/Assets/StreamingAssets/Vehicles.bank (Stored with Git LFS)

Binary file not shown.

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 173ac73c679d2224aa381238b45d2cf5
labels:
- FMOD
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: