ingame graphic options

This commit is contained in:
Le Duc Anh
2026-05-15 13:41:38 +07:00
parent 9e998f9cbc
commit 74985ca09e
6 changed files with 310 additions and 0 deletions
@@ -0,0 +1,41 @@
using UnityEngine;
namespace BrewMonster.Scripts
{
public class InGameOptionButtionTest : MonoBehaviour
{
private bool _isHighQuality = false;
private void Start()
{
SetLowQuality();
}
public void OnGraphicSettingButtonClicked()
{
if (_isHighQuality)
SetLowQuality();
else
SetHighQuality();
}
private void SetLowQuality()
{
InGameOptionManager.Instance.SetRenderDistance(200f);
InGameOptionManager.Instance.SetRenderScale(0.6f);
InGameOptionManager.Instance.SetMSAA(0);
_isHighQuality = false;
}
private void SetHighQuality()
{
InGameOptionManager.Instance.SetRenderDistance(500f);
InGameOptionManager.Instance.SetRenderScale(1f);
InGameOptionManager.Instance.SetMSAA(4);
_isHighQuality = true;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3cc6b94c2473af549a27a71783be1641
@@ -0,0 +1,44 @@
using Unity.Cinemachine;
using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace BrewMonster.Scripts
{
public class InGameOptionManager : MonoSingleton<InGameOptionManager>
{
[SerializeField] private UniversalRenderPipelineAsset _renderPipelineAsset;
[SerializeField] private CinemachineVirtualCamera _cinemachineVirtualCamera;
#region public functions
/// <summary>How far the objects are rendered in the scene.</summary>
/// <param name="distance"></param>
public void SetRenderDistance(float distance)
{
distance = Mathf.Clamp(distance, 50f, 500f);
_cinemachineVirtualCamera.m_Lens.FarClipPlane = distance;
}
/// <summary>
/// The scale of the render pipeline. <br/>
/// The value should be between 0.6 and 1.5.
/// </summary>
public void SetRenderScale(float scale)
{
scale = Mathf.Clamp(scale, 0.6f, 1.5f);
_renderPipelineAsset.renderScale = scale;
}
public void SetMSAA(int msaaLevel)
{
// Valid: 0,2,4
if (msaaLevel != 0 && msaaLevel != 2 && msaaLevel != 4)
return;
_renderPipelineAsset.msaaSampleCount = msaaLevel;
}
#endregion
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cfa24c9da248b9d4aa36c50fb688c146
+214
View File
@@ -0,0 +1,214 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2725964181764938372
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9079041945482710805}
- component: {fileID: 8638675331407853245}
- component: {fileID: 2668140200533103676}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &9079041945482710805
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2725964181764938372}
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7681425590765782574}
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!222 &8638675331407853245
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2725964181764938372}
m_CullTransparentMesh: 1
--- !u!114 &2668140200533103676
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2725964181764938372}
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_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Graphic
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
m_sharedMaterial: {fileID: 9092487103257209053, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4278190080
m_fontColor: {r: 0, 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: 36
m_fontSizeBase: 36
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_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 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: 0
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!1 &4276923075264027147
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7681425590765782574}
- component: {fileID: 1087046858359492222}
- component: {fileID: 602748786618097678}
m_Layer: 5
m_Name: QualityBtn
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7681425590765782574
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4276923075264027147}
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 9079041945482710805}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 183.11, y: -38}
m_SizeDelta: {x: 126.2101, y: 55.4429}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1087046858359492222
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4276923075264027147}
m_CullTransparentMesh: 1
--- !u!114 &602748786618097678
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4276923075264027147}
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_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c136c867abc478f49a5045af11bfd46e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: