Files
AZTECH_WB/Assets/Scripts/UI/SettingPanel/GraphicsSettingContent.cs
정영민 18bc516f1d [정영민] 아즈텍 UI 디자인 변경 및 기능 수정 1차
26.04.03
가상공장 화면 디자인 반영
  • 좌측 도구 창, 상단 UI, 하단 UI
  • 생산 현황판, 알림 현황판
  • 설비 라벨, 요약 팝업, 대시보드, 데이터 보드
  • 설정창, 미니맵, AI 시뮬레이션 결과창, 나가기 팝업
가상 공장 화면 디자인 변경에 따른 기능 추가
  • 미니맵 드래그 및 위치 조정 기능 추가
  • UI 상호 작용(호버링, 선택, 위치 이동, 재설정)
  • UI 기능 추가(상태 표시, 색상)
2026-04-03 11:50:05 +09:00

145 lines
6.0 KiB
C#

using UnityEngine;
using UnityEngine.Rendering.Universal;
using UnityEngine.Rendering;
using AZTECHWB.Management;
using AZTECHWB.Extensions;
namespace AZTECHWB.UI
{
public class GraphicsSettingContent : MonoBehaviour
{
private OptionManager optionManager;
private UniversalRenderPipelineAsset urpAsset;
private GraphicsSettingItem ResolutionItem;
private GraphicsSettingItem TextureQualityItem;
private GraphicsSettingItem ShadowQualityItem;
private GraphicsSettingItem AntiAliasingItem;
private GraphicsSettingItem VSyncItem;
private GraphicsSettingItem AnisotropicFilteringItem;
Vector2Int[] resolutions = { new(1280, 720), new(1600, 900), new(1920, 1080), new(2560, 1440) };
FullScreenMode[] screenModes = { FullScreenMode.ExclusiveFullScreen, FullScreenMode.FullScreenWindow, FullScreenMode.Windowed };
string[] textureNames = { "높음", "중간", "낮음" };
string[] shadowNames = { "끄기", "낮음", "중간", "높음" };
string[] aaNames = { "끄기", "MSAA x2", "MSAA x4", "MSAA x8" };
int[] aaValues = { 0, 2, 4, 8 };
int resIndex, screenModeIndex, textureIndex, shadowIndex, aaIndex, vSync, afIndex;
public void Init()
{
transform.TryGetComponentInChildren(nameof(ResolutionItem), out ResolutionItem);
transform.TryGetComponentInChildren(nameof(TextureQualityItem), out TextureQualityItem);
transform.TryGetComponentInChildren(nameof(ShadowQualityItem), out ShadowQualityItem);
transform.TryGetComponentInChildren(nameof(AntiAliasingItem), out AntiAliasingItem);
transform.TryGetComponentInChildren(nameof(VSyncItem), out VSyncItem);
transform.TryGetComponentInChildren(nameof(AnisotropicFilteringItem), out AnisotropicFilteringItem);
string[] resolutionNames = new string[resolutions.Length];
for (int i = 0; i < resolutions.Length; i++)
resolutionNames[i] = $"{resolutions[i].x} x {resolutions[i].y}";
ResolutionItem.InitDropdown(v => resIndex = v);
ResolutionItem.SetDropdownOptions(resolutionNames);
TextureQualityItem.InitDropdown(v => textureIndex = v);
TextureQualityItem.SetDropdownOptions(textureNames);
ShadowQualityItem.InitDropdown(v => shadowIndex = v);
ShadowQualityItem.SetDropdownOptions(shadowNames);
AntiAliasingItem.InitDropdown(v => aaIndex = v);
AntiAliasingItem.SetDropdownOptions(aaNames);
VSyncItem.InitToggle(v => vSync = v ? 1 : 0);
AnisotropicFilteringItem.InitToggle(v => afIndex = v ? 1 : 0);
optionManager = FindAnyObjectByType<OptionManager>();
urpAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
optionManager.onCompletedLoadOption += ApplyIniToUI;
}
public void ApplyIniToUI()
{
resIndex = GetResolutionIndex(optionManager.GetValue("Graphics", "Resolution"));
screenModeIndex = int.Parse(optionManager.GetValue("Graphics", "ScreenMode", "0"));
textureIndex = int.Parse(optionManager.GetValue("Graphics", "Texture", "0"));
shadowIndex = int.Parse(optionManager.GetValue("Graphics", "Shadow", "2"));
aaIndex = int.Parse(optionManager.GetValue("Graphics", "AA", "2"));
vSync = int.Parse(optionManager.GetValue("Graphics", "VSync", "1"));
afIndex = int.Parse(optionManager.GetValue("Graphics", "AF", "1"));
RefreshUI();
}
public void Apply()
{
var r = resolutions[resIndex];
optionManager.SetValue("Graphics", "Resolution", $"{r.x}x{r.y}");
optionManager.SetValue("Graphics", "ScreenMode", screenModeIndex.ToString());
optionManager.SetValue("Graphics", "Texture", textureIndex.ToString());
optionManager.SetValue("Graphics", "Shadow", shadowIndex.ToString());
optionManager.SetValue("Graphics", "AA", aaIndex.ToString());
optionManager.SetValue("Graphics", "VSync", vSync.ToString());
optionManager.SetValue("Graphics", "AF", afIndex.ToString());
Screen.fullScreenMode = screenModes[screenModeIndex];
Screen.SetResolution(r.x, r.y, Screen.fullScreenMode);
QualitySettings.globalTextureMipmapLimit = textureIndex;
QualitySettings.vSyncCount = vSync;
QualitySettings.anisotropicFiltering = (AnisotropicFiltering)afIndex;
ApplyURPShadow();
ApplyURPAntiAliasing();
}
void ApplyURPShadow()
{
if (urpAsset == null) return;
urpAsset.shadowDistance = shadowIndex switch
{
0 => 0,
1 => 20,
2 => 50,
3 => 100,
_ => 50
};
}
void ApplyURPAntiAliasing()
{
if (urpAsset == null) return;
urpAsset.msaaSampleCount = aaValues[aaIndex];
var cam = Camera.main;
if (cam != null && cam.TryGetComponent(out UniversalAdditionalCameraData data))
{
data.antialiasing = aaValues[aaIndex] == 0 ? AntialiasingMode.None : AntialiasingMode.FastApproximateAntialiasing;
}
}
void RefreshUI()
{
ResolutionItem.SetDropdownValue(resIndex);
TextureQualityItem.SetDropdownValue(textureIndex);
ShadowQualityItem.SetDropdownValue(shadowIndex);
AntiAliasingItem.SetDropdownValue(aaIndex);
VSyncItem.SetToggleValue(vSync != 0);
AnisotropicFilteringItem.SetToggleValue(afIndex != 0);
}
int GetResolutionIndex(string value)
{
for (int i = 0; i < resolutions.Length; i++)
{
if ($"{resolutions[i].x}x{resolutions[i].y}" == value)
return i;
}
return 2; // 1920x1080
}
}
}