中
This commit is contained in:
89
Assets/ForTest.cs
Normal file
89
Assets/ForTest.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ForTest : MonoBehaviour
|
||||
{
|
||||
public TMPro.TMP_Text mP_Text;
|
||||
// Start is called before the first frame update
|
||||
string source = "87.5\r\n95\r\n87.5\r\n90\r\n95\r\n90\r\n97.5\r\n95\r\n100\r\n77.5\r\n97.5\r\n100\r\n95\r\n95\r\n97.5\r\n85\r\n97.5\r\n92.5\r\n95\r\n87.5\r\n92.5\r\n87.5\r\n95\r\n90\r\n97.5\r\n95\r\n87.5\r\n87.5\r\n90\r\n90\r\n90\r\n92.5\r\n92.5\r\n97.5\r\n95\r\n95\r\n90\r\n90\r\n100\r\n90\r\n100\r\n80\r\n90\r\n97.5\r\n92.5\r\n97.5\r\n80\r\n90\r\n90\r\n87.5\r\n92.5\r\n95\r\n87.5\r\n80\r\n90\r\n100\r\n95\r\n87.5\r\n90\r\n87.5\r\n92.5\r\n95\r\n75\r\n90\r\n92.5\r\n97.5\r\n92.5\r\n90\r\n92.5\r\n100\r\n";
|
||||
void Start()
|
||||
{
|
||||
string _out = "";
|
||||
string[] strs = source.Split("\r\n");
|
||||
foreach (var str in strs)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
float targetAverage = float.Parse(str);
|
||||
List<float> temp = GenerateNumbersFromAverage(targetAverage, 4);
|
||||
string line = "";
|
||||
//foreach (float num in temp)
|
||||
//{
|
||||
// line += num.ToString("F1") + "\t";
|
||||
//}
|
||||
//_out += string.Join("", line) + "\r\n";
|
||||
|
||||
foreach (float num in temp)
|
||||
{
|
||||
line += num.ToString("F1") + "\t";
|
||||
}
|
||||
line += targetAverage.ToString("F1");
|
||||
_out += line + "\r\n";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Debug.Log(_out);
|
||||
mP_Text.text = _out;
|
||||
}
|
||||
|
||||
List<float> GenerateNumbersFromAverage(float targetAverage, int count)
|
||||
{
|
||||
List<float> numbers = new List<float>();
|
||||
float total = targetAverage * count;
|
||||
|
||||
// 生成前4个随机数
|
||||
float currentSum = 0f;
|
||||
for (int i = 0; i < count - 1; i++)
|
||||
{
|
||||
// 确保剩余的数字能够满足平均值要求
|
||||
float remainingTotal = total - currentSum;
|
||||
float maxValue = Mathf.Min(100f, remainingTotal); // 不超过100
|
||||
float minValue = Mathf.Max(60f, remainingTotal - (count - i - 1) * 100f); // 不低于60
|
||||
|
||||
int randomNum = Random.Range((int)minValue, (int)maxValue);
|
||||
numbers.Add(randomNum);
|
||||
currentSum += randomNum;
|
||||
}
|
||||
|
||||
// 计算最后一个数字以确保平均值精确
|
||||
float lastNum = total - currentSum;
|
||||
numbers.Add(lastNum);
|
||||
|
||||
return numbers;
|
||||
}
|
||||
//void Start()
|
||||
//{
|
||||
// string _out = "";
|
||||
// string[] strs = source.Split("\r\n");
|
||||
// foreach (var str in strs)
|
||||
// {
|
||||
// List<string> temp = new List<string>();
|
||||
// for (int i = 0; i < 5; i++)
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(str))
|
||||
// {
|
||||
// float num = float.Parse(str);
|
||||
// num += Random.Range(-100 + num, 100 - num);
|
||||
// temp.Add(num.ToString() + "\t");
|
||||
// }
|
||||
|
||||
// }
|
||||
// _out += string.Join("", temp) + "\r\n";
|
||||
|
||||
// }
|
||||
// Debug.Log(_out);
|
||||
// mP_Text.text = _out;
|
||||
//}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b16c03c5d0a387641a3c978840f52037
|
||||
guid: 289ff0037da069d4eabdb31ba944ce72
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -122,6 +122,74 @@ NavMeshSettings:
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &109037209
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 109037212}
|
||||
- component: {fileID: 109037211}
|
||||
- component: {fileID: 109037210}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &109037210
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 109037209}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_HorizontalAxis: Horizontal
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
m_InputActionsPerSecond: 10
|
||||
m_RepeatDelay: 0.5
|
||||
m_ForceModuleActive: 0
|
||||
--- !u!114 &109037211
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 109037209}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 1
|
||||
m_DragThreshold: 10
|
||||
--- !u!4 &109037212
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 109037209}
|
||||
serializedVersion: 2
|
||||
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: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &444951594
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -252,6 +320,7 @@ GameObject:
|
||||
- component: {fileID: 488143181}
|
||||
- component: {fileID: 488143180}
|
||||
- component: {fileID: 488143179}
|
||||
- component: {fileID: 488143183}
|
||||
m_Layer: 0
|
||||
m_Name: Camera
|
||||
m_TagString: Untagged
|
||||
@@ -377,6 +446,255 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &488143183
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 488143178}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 289ff0037da069d4eabdb31ba944ce72, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
mP_Text: {fileID: 2090581202}
|
||||
--- !u!1 &1167915817
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1167915821}
|
||||
- component: {fileID: 1167915820}
|
||||
- component: {fileID: 1167915819}
|
||||
- component: {fileID: 1167915818}
|
||||
m_Layer: 5
|
||||
m_Name: Canvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1167915818
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1167915817}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &1167915819
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1167915817}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
--- !u!223 &1167915820
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1167915817}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!224 &1167915821
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1167915817}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 2090581201}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1 &2090581200
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2090581201}
|
||||
- component: {fileID: 2090581203}
|
||||
- component: {fileID: 2090581202}
|
||||
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 &2090581201
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2090581200}
|
||||
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: 1167915821}
|
||||
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: 200, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &2090581202
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2090581200}
|
||||
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: New Text
|
||||
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: 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: 1
|
||||
m_VerticalAlignment: 256
|
||||
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: 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!222 &2090581203
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2090581200}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &2139286200
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -477,3 +795,5 @@ SceneRoots:
|
||||
- {fileID: 444951596}
|
||||
- {fileID: 2139286203}
|
||||
- {fileID: 488143182}
|
||||
- {fileID: 1167915821}
|
||||
- {fileID: 109037212}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,20 +15,20 @@ public class GameStart : MonoBehaviour
|
||||
|
||||
IEnumerator StartupSequence()
|
||||
{
|
||||
Debug.Log("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
|
||||
Debug.Log("开始游戏启动流程...");
|
||||
|
||||
yield return StartCoroutine(InitializeGameSystems());
|
||||
|
||||
yield return StartCoroutine(LoadMainScene());
|
||||
|
||||
Debug.Log("<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
Debug.Log("游戏启动流程完成");
|
||||
}
|
||||
|
||||
IEnumerator InitializeGameSystems()
|
||||
{
|
||||
Debug.Log("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸϵͳ...");
|
||||
Debug.Log("初始化游戏系统...");
|
||||
GameSystem.Inst.Init();
|
||||
Debug.Log("<EFBFBD><EFBFBD>Ϸϵͳ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
Debug.Log("游戏系统初始化完成");
|
||||
yield return null;
|
||||
}
|
||||
IEnumerator LoadMainScene()
|
||||
|
||||
@@ -4,15 +4,11 @@ using UnityEngine;
|
||||
|
||||
public class GameSystem : Singleton<GameSystem>
|
||||
{
|
||||
public UIManager UI { get; private set; }
|
||||
public SettingsManager Settings { get; private set; }
|
||||
|
||||
public GraphicsManager Graphics { get; private set; }
|
||||
public void Init()
|
||||
{
|
||||
UI = UIManager.Inst;
|
||||
Settings = SettingsManager.Inst;
|
||||
Graphics = GraphicsManager.Inst;
|
||||
UIManager.Inst.Init();
|
||||
SettingsManager.Inst.Init();
|
||||
GraphicsManager.Inst.Init();
|
||||
AudioManager.Inst.Init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ public class NetWorkThirdCharacterController : NetworkBehaviour
|
||||
{
|
||||
isCursorLocked = !isCursorLocked;
|
||||
UpdateCursorState();
|
||||
if (GameSystem.Inst.UI.CheckShow(nameof(SettingsWindow)))
|
||||
if (UIManager.Inst.CheckShow(nameof(SettingsWindow)))
|
||||
{
|
||||
GameSystem.Inst.UI.HideWindow(nameof(SettingsWindow));
|
||||
UIManager.Inst.HideWindow(nameof(SettingsWindow));
|
||||
}
|
||||
else
|
||||
{
|
||||
GameSystem.Inst.UI.ShowWindow<SettingsWindow>(nameof(SettingsWindow));
|
||||
UIManager.Inst.ShowWindow<SettingsWindow>(nameof(SettingsWindow));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,13 +115,13 @@ public class ThirdCharacterController : MonoBehaviour
|
||||
{
|
||||
isCursorLocked = !isCursorLocked;
|
||||
UpdateCursorState();
|
||||
if (GameSystem.Inst.UI.CheckShow(nameof(SettingsWindow)))
|
||||
if (UIManager.Inst.CheckShow(nameof(SettingsWindow)))
|
||||
{
|
||||
GameSystem.Inst.UI.HideWindow(nameof(SettingsWindow));
|
||||
UIManager.Inst.HideWindow(nameof(SettingsWindow));
|
||||
}
|
||||
else
|
||||
{
|
||||
GameSystem.Inst.UI.ShowWindow<SettingsWindow>(nameof(SettingsWindow));
|
||||
UIManager.Inst.ShowWindow<SettingsWindow>(nameof(SettingsWindow));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AudioManager : Singleton<AudioManager>
|
||||
{
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ea56a12bf5c53a4785e752b3a7c00b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,22 +6,21 @@ public class AudioPanel : UIBasePanel, ISettingsPanel
|
||||
{
|
||||
[SerializeField] private Slider masterVolumeSlider;
|
||||
[SerializeField] private AudioMixer audioMixer;
|
||||
float masterVolume;
|
||||
public override void OnShow()
|
||||
{
|
||||
masterVolume = masterVolumeSlider.value = SettingsManager.Inst.CurrentSettings.masterVolume;
|
||||
masterVolumeSlider.value = SettingsManager.Inst.CurrentSettings.masterVolume;
|
||||
if (audioMixer == null) audioMixer = FindAnyObjectByType<AudioMixer>();
|
||||
}
|
||||
|
||||
public void OnMasterVolumeChanged(float value)
|
||||
{
|
||||
masterVolume = value;
|
||||
SettingsManager.Inst.CurrentSettings.masterVolume = value;
|
||||
SetVolume(value);
|
||||
}
|
||||
|
||||
public void ApplySettings()
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.masterVolume = masterVolume;
|
||||
|
||||
}
|
||||
|
||||
private void SetVolume(float volume)
|
||||
@@ -32,6 +31,6 @@ public class AudioPanel : UIBasePanel, ISettingsPanel
|
||||
|
||||
public void ResetToDefault()
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.masterVolume = masterVolume = SettingsManager.Inst.DefSetting.masterVolume;
|
||||
SettingsManager.Inst.CurrentSettings.masterVolume = SettingsManager.Inst.DefSetting.masterVolume;
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using System.Collections;
|
||||
|
||||
public class DisplayPanel : UIBasePanel, ISettingsPanel
|
||||
{
|
||||
[Header("UI References")]
|
||||
[SerializeField] private TMP_Dropdown resolutionDropdown;
|
||||
[SerializeField] private Toggle fullscreenToggle;
|
||||
[SerializeField] private Toggle borderlessToggle;
|
||||
[SerializeField] private TMP_Dropdown displayDropdown;
|
||||
|
||||
private Resolution[] resolutions;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitializeResolutionDropdown();
|
||||
InitializeDisplayDropdown();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
StartCoroutine(InitializeDelayed());
|
||||
}
|
||||
IEnumerator InitializeDelayed()
|
||||
{
|
||||
yield return null;
|
||||
var settings = SettingsManager.Inst.CurrentSettings;
|
||||
|
||||
resolutionDropdown.SetValueWithoutNotify(settings.resolutionIndex);
|
||||
fullscreenToggle.SetIsOnWithoutNotify(settings.fullscreen);
|
||||
borderlessToggle.SetIsOnWithoutNotify(settings.borderless);
|
||||
displayDropdown.SetValueWithoutNotify(settings.displayIndex);
|
||||
|
||||
UpdateBorderlessToggleState();
|
||||
}
|
||||
|
||||
private void InitializeResolutionDropdown()
|
||||
{
|
||||
resolutions = Screen.resolutions;
|
||||
resolutionDropdown.ClearOptions();
|
||||
|
||||
var options = new List<string>();
|
||||
for (int i = 0; i < resolutions.Length; i++)
|
||||
{
|
||||
int refreshRate = Mathf.RoundToInt((float)resolutions[i].refreshRateRatio.value);
|
||||
options.Add($"{resolutions[i].width}x{resolutions[i].height} {refreshRate}Hz");
|
||||
}
|
||||
|
||||
resolutionDropdown.AddOptions(options);
|
||||
}
|
||||
|
||||
private void InitializeDisplayDropdown()
|
||||
{
|
||||
displayDropdown.ClearOptions();
|
||||
var options = new List<string>();
|
||||
|
||||
for (int i = 0; i < Display.displays.Length; i++)
|
||||
{
|
||||
options.Add($"Display {i + 1}");
|
||||
}
|
||||
|
||||
displayDropdown.AddOptions(options);
|
||||
}
|
||||
|
||||
public void OnResolutionChanged(int index)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.resolutionIndex = index;
|
||||
ApplySetResolution();
|
||||
}
|
||||
|
||||
public void OnFullscreenChanged(bool value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.fullscreen = value;
|
||||
UpdateBorderlessToggleState();
|
||||
ApplySetResolution();
|
||||
}
|
||||
|
||||
public void OnBorderlessChanged(bool value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.borderless = value;
|
||||
ApplySetResolution();
|
||||
}
|
||||
|
||||
public void OnDisplayChanged(int index)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.displayIndex = index;
|
||||
ApplySetDisplay();
|
||||
}
|
||||
|
||||
private void UpdateBorderlessToggleState()
|
||||
{
|
||||
borderlessToggle.interactable = fullscreenToggle.isOn;
|
||||
if (!fullscreenToggle.isOn)
|
||||
borderlessToggle.isOn = false;
|
||||
ApplySetResolution();
|
||||
}
|
||||
|
||||
public void ApplySettings()
|
||||
{
|
||||
ApplySetResolution();
|
||||
|
||||
ApplySetDisplay();
|
||||
}
|
||||
void ApplySetResolution()
|
||||
{
|
||||
if (resolutions == null) return;
|
||||
var settings = SettingsManager.Inst.CurrentSettings;
|
||||
Resolution res = resolutions[resolutions.Length-1];
|
||||
if (settings.resolutionIndex < resolutions.Length && settings.resolutionIndex>=0)
|
||||
{
|
||||
res = resolutions[settings.resolutionIndex];
|
||||
}
|
||||
|
||||
FullScreenMode mode = settings.borderless ?
|
||||
FullScreenMode.FullScreenWindow :
|
||||
(settings.fullscreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.Windowed);
|
||||
|
||||
Screen.SetResolution(
|
||||
res.width,
|
||||
res.height,
|
||||
mode,
|
||||
res.refreshRateRatio
|
||||
);
|
||||
}
|
||||
void ApplySetDisplay()
|
||||
{
|
||||
var settings = SettingsManager.Inst.CurrentSettings;
|
||||
if (settings.displayIndex > 0 && settings.displayIndex < Display.displays.Length)
|
||||
{
|
||||
Display.displays[settings.displayIndex].Activate();
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetToDefault()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -5,22 +5,21 @@ using UnityEngine.UI;
|
||||
public class GeneralPanel : UIBasePanel,ISettingsPanel
|
||||
{
|
||||
[SerializeField] private TMP_InputField serverAddressInput;
|
||||
string serverAddress;
|
||||
public override void OnShow()
|
||||
{
|
||||
serverAddressInput.text = SettingsManager.Inst.CurrentSettings.serverAddress;
|
||||
}
|
||||
public void OnServerAddressChanged(string value)
|
||||
{
|
||||
serverAddress = value;
|
||||
SettingsManager.Inst.CurrentSettings.serverAddress = value;
|
||||
}
|
||||
public void ApplySettings()
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.serverAddress = serverAddress;
|
||||
|
||||
}
|
||||
|
||||
public void ResetToDefault()
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.serverAddress = serverAddress = SettingsManager.Inst.DefSetting.serverAddress;
|
||||
SettingsManager.Inst.CurrentSettings.serverAddress = SettingsManager.Inst.DefSetting.serverAddress;
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,9 @@ using YooAsset;
|
||||
|
||||
public class GraphicsManager : Singleton<GraphicsManager>
|
||||
{
|
||||
public GraphicsSetting graphicsSetting;
|
||||
private UniversalRenderPipelineAsset _urpAsset;
|
||||
private VolumeProfile urpVolumeProfile;
|
||||
public GraphicsManager()
|
||||
public void Init()
|
||||
{
|
||||
_urpAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||
|
||||
@@ -24,17 +23,50 @@ public class GraphicsManager : Singleton<GraphicsManager>
|
||||
{
|
||||
Debug.LogError("VolumeProfile null");
|
||||
}
|
||||
graphicsSetting = SettingsManager.Inst.CurrentSettings.graphicsSettings;
|
||||
ApplySettings();
|
||||
}
|
||||
public void ApplySettings()
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings = graphicsSetting;
|
||||
GraphicsSetting graphicsSetting = SettingsManager.Inst.CurrentSettings.graphicsSettings;
|
||||
SettingsManager.Inst.SaveSettings();
|
||||
ApplySetURPAsset(graphicsSetting);
|
||||
ApplySetResolution(graphicsSetting);
|
||||
ApplySetDisplay(graphicsSetting);
|
||||
}
|
||||
void ApplySetURPAsset(GraphicsSetting graphicsSetting)
|
||||
{
|
||||
QualitySettings.vSyncCount = graphicsSetting.vsyncEnabled ? 1 : 0;
|
||||
_urpAsset.shadowDistance = graphicsSetting.shadowDistance;
|
||||
_urpAsset.msaaSampleCount = (int)Mathf.Pow(2, graphicsSetting.qualityLevel);
|
||||
_urpAsset.renderScale = graphicsSetting.renderScale;
|
||||
}
|
||||
void ApplySetResolution(GraphicsSetting graphicsSetting)
|
||||
{
|
||||
if (Screen.resolutions == null) return;
|
||||
Resolution res = Screen.resolutions[Screen.resolutions.Length - 1];
|
||||
if (graphicsSetting.resolutionIndex < Screen.resolutions.Length && graphicsSetting.resolutionIndex >= 0)
|
||||
{
|
||||
res = Screen.resolutions[graphicsSetting.resolutionIndex];
|
||||
}
|
||||
|
||||
FullScreenMode mode = graphicsSetting.borderless ?
|
||||
FullScreenMode.FullScreenWindow :
|
||||
(graphicsSetting.fullscreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.Windowed);
|
||||
|
||||
Screen.SetResolution(
|
||||
res.width,
|
||||
res.height,
|
||||
mode,
|
||||
res.refreshRateRatio
|
||||
);
|
||||
}
|
||||
void ApplySetDisplay(GraphicsSetting graphicsSetting)
|
||||
{
|
||||
if (graphicsSetting.displayIndex > 0 && graphicsSetting.displayIndex < Display.displays.Length)
|
||||
{
|
||||
Display.displays[graphicsSetting.displayIndex].Activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
[System.Serializable]
|
||||
public class GraphicsSetting
|
||||
@@ -47,6 +79,11 @@ public class GraphicsSetting
|
||||
public float renderScale = 1.0f;
|
||||
public bool isCustom = false;
|
||||
|
||||
public int resolutionIndex = 0;
|
||||
public bool fullscreen = true;
|
||||
public bool borderless = false;
|
||||
public int displayIndex = 0;
|
||||
|
||||
public GraphicsSetting() { }
|
||||
|
||||
public GraphicsSetting(int quality, bool vsync, float shadows, int aa, bool bloom, float scale)
|
||||
|
||||
@@ -4,6 +4,7 @@ using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using TMPro;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class GraphicsPanel : UIBasePanel, ISettingsPanel
|
||||
{
|
||||
@@ -15,55 +16,128 @@ public class GraphicsPanel : UIBasePanel, ISettingsPanel
|
||||
[SerializeField] private Toggle bloomToggle;
|
||||
[SerializeField] private Slider renderScaleSlider;
|
||||
|
||||
[SerializeField] private TMP_Dropdown resolutionDropdown;
|
||||
[SerializeField] private Toggle fullscreenToggle;
|
||||
[SerializeField] private Toggle borderlessToggle;
|
||||
[SerializeField] private TMP_Dropdown displayDropdown;
|
||||
|
||||
private Resolution[] resolutions;
|
||||
bool init = false;
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
var settings = SettingsManager.Inst.CurrentSettings;
|
||||
var settings =SettingsManager.Inst.CurrentSettings;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
InitializeResolutionDropdown();
|
||||
InitializeDisplayDropdown();
|
||||
}
|
||||
|
||||
qualityDropdown.SetValueWithoutNotify(settings.graphicsSettings.qualityLevel);
|
||||
vsyncToggle.SetIsOnWithoutNotify(settings.graphicsSettings.vsyncEnabled);
|
||||
shadowDistanceSlider.SetValueWithoutNotify(settings.graphicsSettings.shadowDistance);
|
||||
antiAliasingDropdown.SetValueWithoutNotify(settings.graphicsSettings.antiAliasing);
|
||||
bloomToggle.SetIsOnWithoutNotify(settings.graphicsSettings.bloomEnabled);
|
||||
renderScaleSlider.SetValueWithoutNotify(settings.graphicsSettings.renderScale);
|
||||
|
||||
resolutionDropdown.SetValueWithoutNotify(settings.graphicsSettings.resolutionIndex);
|
||||
fullscreenToggle.SetIsOnWithoutNotify(settings.graphicsSettings.fullscreen);
|
||||
borderlessToggle.SetIsOnWithoutNotify(settings.graphicsSettings.borderless);
|
||||
displayDropdown.SetValueWithoutNotify(settings.graphicsSettings.displayIndex);
|
||||
}
|
||||
private void InitializeResolutionDropdown()
|
||||
{
|
||||
resolutions = Screen.resolutions;
|
||||
resolutionDropdown.ClearOptions();
|
||||
|
||||
var options = new List<string>();
|
||||
for (int i = 0; i < resolutions.Length; i++)
|
||||
{
|
||||
int refreshRate = Mathf.RoundToInt((float)resolutions[i].refreshRateRatio.value);
|
||||
options.Add($"{resolutions[i].width}x{resolutions[i].height} {refreshRate}Hz");
|
||||
}
|
||||
|
||||
resolutionDropdown.AddOptions(options);
|
||||
}
|
||||
|
||||
private void InitializeDisplayDropdown()
|
||||
{
|
||||
displayDropdown.ClearOptions();
|
||||
var options = new List<string>();
|
||||
|
||||
for (int i = 0; i < Display.displays.Length; i++)
|
||||
{
|
||||
options.Add($"Display {i + 1}");
|
||||
}
|
||||
|
||||
displayDropdown.AddOptions(options);
|
||||
}
|
||||
|
||||
public void OnQualityChanged(int index)
|
||||
{
|
||||
GameSystem.Inst.Graphics.graphicsSetting.qualityLevel = index;
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.qualityLevel = index;
|
||||
}
|
||||
|
||||
public void OnVSyncChanged(bool value)
|
||||
{
|
||||
GameSystem.Inst.Graphics.graphicsSetting.vsyncEnabled = value;
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.vsyncEnabled = value;
|
||||
}
|
||||
|
||||
public void OnShadowDistanceChanged(float value)
|
||||
{
|
||||
GameSystem.Inst.Graphics.graphicsSetting.shadowDistance = value;
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.shadowDistance = value;
|
||||
}
|
||||
|
||||
public void OnAntiAliasingChanged(int index)
|
||||
{
|
||||
GameSystem.Inst.Graphics.graphicsSetting.antiAliasing = index;
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.antiAliasing = index;
|
||||
}
|
||||
|
||||
public void OnBloomChanged(bool value)
|
||||
{
|
||||
GameSystem.Inst.Graphics.graphicsSetting.bloomEnabled = value;
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.bloomEnabled = value;
|
||||
}
|
||||
|
||||
public void OnRenderScaleChanged(float value)
|
||||
{
|
||||
GameSystem.Inst.Graphics.graphicsSetting.renderScale = value;
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.renderScale = value;
|
||||
}
|
||||
public void OnResolutionChanged(int index)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.resolutionIndex = index;
|
||||
}
|
||||
|
||||
public void OnFullscreenChanged(bool value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.fullscreen = value;
|
||||
UpdateBorderlessToggleState();
|
||||
}
|
||||
|
||||
public void OnBorderlessChanged(bool value)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.borderless = value;
|
||||
}
|
||||
|
||||
public void OnDisplayChanged(int index)
|
||||
{
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings.displayIndex = index;
|
||||
}
|
||||
|
||||
private void UpdateBorderlessToggleState()
|
||||
{
|
||||
borderlessToggle.interactable = fullscreenToggle.isOn;
|
||||
if (!fullscreenToggle.isOn)
|
||||
borderlessToggle.isOn = false;
|
||||
}
|
||||
|
||||
public void ApplySettings()
|
||||
{
|
||||
GameSystem.Inst.Graphics.ApplySettings();
|
||||
GraphicsManager.Inst.ApplySettings();
|
||||
}
|
||||
|
||||
public void ResetToDefault()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
SettingsManager.Inst.CurrentSettings.graphicsSettings = SettingsManager.Inst.DefSetting.graphicsSettings;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using UnityEngine;
|
||||
using System.IO;
|
||||
using YooAsset;
|
||||
using System;
|
||||
using System.Drawing.Printing;
|
||||
|
||||
public class SettingsManager: Singleton<SettingsManager>
|
||||
{
|
||||
@@ -9,7 +10,7 @@ public class SettingsManager: Singleton<SettingsManager>
|
||||
public GameSettings CurrentSettings => _currentSettings;
|
||||
public GameSettings DefSetting = new GameSettings();
|
||||
private string settingsPath;
|
||||
public SettingsManager()
|
||||
public void Init()
|
||||
{
|
||||
settingsPath = Path.Combine(Application.persistentDataPath, "settings.json");
|
||||
LoadSettings();
|
||||
@@ -34,16 +35,16 @@ public class SettingsManager: Singleton<SettingsManager>
|
||||
string json = JsonUtility.ToJson(_currentSettings, true);
|
||||
File.WriteAllText(settingsPath, json);
|
||||
}
|
||||
#region 图像
|
||||
#endregion 图像
|
||||
|
||||
#region 其他
|
||||
#endregion 其他
|
||||
public void ResetToDefaultSettings()
|
||||
{
|
||||
_currentSettings = DefSetting;
|
||||
SaveSettings();
|
||||
}
|
||||
public void ApplyAllSettings()
|
||||
{
|
||||
GraphicsManager.Inst.ApplySettings();
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
@@ -53,18 +54,7 @@ public class GameSettings
|
||||
|
||||
public float masterVolume = 0.75f;
|
||||
|
||||
//public int qualityLevel = 2;
|
||||
//public bool vsyncEnabled = true;
|
||||
//public float shadowDistance = 50f;
|
||||
//public int antiAliasing = 2;
|
||||
//public bool bloomEnabled = true;
|
||||
//public float renderScale = 1.0f;
|
||||
public GraphicsSetting graphicsSettings;
|
||||
|
||||
public int resolutionIndex = 0;
|
||||
public bool fullscreen = true;
|
||||
public bool borderless = false;
|
||||
public int displayIndex = 0;
|
||||
}
|
||||
public interface ISettingsPanel
|
||||
{
|
||||
|
||||
@@ -7,13 +7,11 @@ public class SettingsWindow : UIBaseWindow
|
||||
public GeneralPanel generalPanel;
|
||||
public AudioPanel audioPanel;
|
||||
public GraphicsPanel graphicsPanel;
|
||||
public DisplayPanel displayPanel;
|
||||
|
||||
[Header("Tab Buttons")]
|
||||
public Button generalTab;
|
||||
public Button audioTab;
|
||||
public Button graphicsTab;
|
||||
public Button displayTab;
|
||||
|
||||
[Header("Action Buttons")]
|
||||
public Button applyButton;
|
||||
@@ -31,7 +29,6 @@ public class SettingsWindow : UIBaseWindow
|
||||
generalTab.onClick.AddListener(() => SwitchPanel(generalPanel));
|
||||
audioTab.onClick.AddListener(() => SwitchPanel(audioPanel));
|
||||
graphicsTab.onClick.AddListener(() => SwitchPanel(graphicsPanel));
|
||||
displayTab.onClick.AddListener(() => SwitchPanel(displayPanel));
|
||||
|
||||
applyButton.onClick.AddListener(ApplyAllSettings);
|
||||
cancelButton.onClick.AddListener(() => { UIManager.Inst.HideWindow(nameof(SettingsWindow)); });
|
||||
@@ -45,9 +42,10 @@ public class SettingsWindow : UIBaseWindow
|
||||
private void SwitchPanel(UIBasePanel newPanel)
|
||||
{
|
||||
if (currentPanel != null)
|
||||
currentPanel.gameObject.SetActive(false);
|
||||
|
||||
newPanel.gameObject.SetActive(true);
|
||||
{
|
||||
currentPanel.Hide();
|
||||
}
|
||||
newPanel.Show();
|
||||
currentPanel = newPanel;
|
||||
UpdateTabButtons();
|
||||
}
|
||||
@@ -57,21 +55,11 @@ public class SettingsWindow : UIBaseWindow
|
||||
generalTab.interactable = currentPanel != generalPanel;
|
||||
audioTab.interactable = currentPanel != audioPanel;
|
||||
graphicsTab.interactable = currentPanel != graphicsPanel;
|
||||
displayTab.interactable = currentPanel != displayPanel;
|
||||
}
|
||||
|
||||
public void ApplyAllSettings()
|
||||
{
|
||||
generalPanel.ApplySettings();
|
||||
|
||||
displayPanel.ApplySettings();
|
||||
|
||||
graphicsPanel.ApplySettings();
|
||||
|
||||
audioPanel.ApplySettings();
|
||||
|
||||
SettingsManager.Inst.SaveSettings();
|
||||
|
||||
SettingsManager.Inst.ApplyAllSettings();
|
||||
UIManager.Inst.HideWindow(nameof(SettingsWindow));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,11 @@ using YooAsset;
|
||||
|
||||
public class UIManager : Singleton<UIManager>
|
||||
{
|
||||
Transform uiRoot;
|
||||
Dictionary<string, UIBaseWindow> openedWindows = new Dictionary<string, UIBaseWindow>();
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
public void ShowWindow<T>(string windowName,Action<T> onShow = null) where T : UIBaseWindow
|
||||
{
|
||||
if (openedWindows.ContainsKey(windowName))
|
||||
@@ -36,7 +39,7 @@ public class UIManager : Singleton<UIManager>
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("δ<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>ڣ<EFBFBD>ʹ<EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
Debug.Log("未找到该名字窗口,使用窗口类名试试");
|
||||
}
|
||||
}
|
||||
public bool CheckShow(string windowName)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
</Group>
|
||||
<Group GroupActiveRule="EnableGroup" GroupName="Setting" GroupDesc="" AssetTags="">
|
||||
<Collector CollectPath="Assets/Settings/SampleSceneProfile.asset" CollectGUID="a6560a915ef98420e9faacc1c7438823" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Settings/AudioMixer.mixer" CollectGUID="8c149e50a4c309540873233c573bd588" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||
</Group>
|
||||
</Package>
|
||||
</root>
|
||||
@@ -149,3 +149,11 @@ MonoBehaviour:
|
||||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
UserData:
|
||||
- CollectPath: Assets/Settings/AudioMixer.mixer
|
||||
CollectorGUID: 8c149e50a4c309540873233c573bd588
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackDirectory
|
||||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
UserData:
|
||||
|
||||
71
Assets/Settings/AudioMixer.mixer
Normal file
71
Assets/Settings/AudioMixer.mixer
Normal file
@@ -0,0 +1,71 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!241 &24100000
|
||||
AudioMixerController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Assets/Settings/AudioMixer.mixer
|
||||
m_OutputGroup: {fileID: 0}
|
||||
m_MasterGroup: {fileID: 24300002}
|
||||
m_Snapshots:
|
||||
- {fileID: 24500006}
|
||||
m_StartSnapshot: {fileID: 24500006}
|
||||
m_SuspendThreshold: -80
|
||||
m_EnableSuspend: 1
|
||||
m_UpdateMode: 0
|
||||
m_ExposedParameters:
|
||||
- guid: bb297a9f27879ec45be00ad9bf9f9970
|
||||
name: MyExposedParam
|
||||
m_AudioMixerGroupViews:
|
||||
- guids:
|
||||
- ddfb54c0912d4fa45bd54a46da154aee
|
||||
name: View
|
||||
m_CurrentViewIndex: 0
|
||||
m_TargetSnapshot: {fileID: 24500006}
|
||||
--- !u!243 &24300002
|
||||
AudioMixerGroupController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Master
|
||||
m_AudioMixer: {fileID: 24100000}
|
||||
m_GroupID: ddfb54c0912d4fa45bd54a46da154aee
|
||||
m_Children: []
|
||||
m_Volume: bb297a9f27879ec45be00ad9bf9f9970
|
||||
m_Pitch: cb721b2ad2523a9489a3eafa9d3702ba
|
||||
m_Send: 00000000000000000000000000000000
|
||||
m_Effects:
|
||||
- {fileID: 24400004}
|
||||
m_UserColorIndex: 0
|
||||
m_Mute: 0
|
||||
m_Solo: 0
|
||||
m_BypassEffects: 0
|
||||
--- !u!244 &24400004
|
||||
AudioMixerEffectController:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_EffectID: ebd857fa945da7f479c09d2af1785983
|
||||
m_EffectName: Attenuation
|
||||
m_MixLevel: 7073ca2fa7248854481ecf6cadad6910
|
||||
m_Parameters: []
|
||||
m_SendTarget: {fileID: 0}
|
||||
m_EnableWetMix: 0
|
||||
m_Bypass: 0
|
||||
--- !u!245 &24500006
|
||||
AudioMixerSnapshotController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Snapshot
|
||||
m_AudioMixer: {fileID: 24100000}
|
||||
m_SnapshotID: 7c30f79d56fe5f64e85ac505794486c7
|
||||
m_FloatValues:
|
||||
bb297a9f27879ec45be00ad9bf9f9970: -0.16685188
|
||||
m_TransitionOverrides: {}
|
||||
8
Assets/Settings/AudioMixer.mixer.meta
Normal file
8
Assets/Settings/AudioMixer.mixer.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c149e50a4c309540873233c573bd588
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 24100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user