From 5365c0749f6d54f61e5f6b3b26ac504d77dc1682 Mon Sep 17 00:00:00 2001 From: Koha9 Date: Wed, 11 Oct 2023 03:10:21 +0900 Subject: [PATCH] =?UTF-8?q?V3.3.9=20LevelProbabilityPanel=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9Inputfiled=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LevelProbabilityPanel追加对Inputfiled支持 --- .../AttackBlock/Attack-AllLevel-Prefabs.asset | 5 + .../Prefeb/AttackBlock/Attack-Level-3.asset | 10 +- .../Prefeb/AttackBlock/Attack-Level-4.asset | 10 +- .../Prefeb/AttackBlock/Attack-Level-5.asset | 5 +- .../SingleLevelProbabilityPanel.prefab | 7 +- Assets/TargetLevelProbabilityPanel.cs | 34 ++++- UserSettings/Layouts/default-2021.dwlt | 116 +++++++++--------- 7 files changed, 118 insertions(+), 69 deletions(-) diff --git a/Assets/Prefeb/AttackBlock/Attack-AllLevel-Prefabs.asset b/Assets/Prefeb/AttackBlock/Attack-AllLevel-Prefabs.asset index 36eadfa..933458b 100644 --- a/Assets/Prefeb/AttackBlock/Attack-AllLevel-Prefabs.asset +++ b/Assets/Prefeb/AttackBlock/Attack-AllLevel-Prefabs.asset @@ -14,3 +14,8 @@ MonoBehaviour: m_EditorClassIdentifier: singleLevelSet: - {fileID: 11400000, guid: 8fc444f0771edf64f8bfc352977d8597, type: 2} + - {fileID: 11400000, guid: 824206b6150173f4ab356e3cab2011c1, type: 2} + - {fileID: 11400000, guid: bf01cc7b27025bb42b08f85f974dffdc, type: 2} + - {fileID: 11400000, guid: 20e2f42b37b20f54b90e75d1cd18fefd, type: 2} + - {fileID: 11400000, guid: 95510ba257a6a6b4090e442ac0ebdea4, type: 2} + - {fileID: 11400000, guid: 89a57384b37c260478f5ae0d8f6e4e70, type: 2} diff --git a/Assets/Prefeb/AttackBlock/Attack-Level-3.asset b/Assets/Prefeb/AttackBlock/Attack-Level-3.asset index 4a4c760..f970d2b 100644 --- a/Assets/Prefeb/AttackBlock/Attack-Level-3.asset +++ b/Assets/Prefeb/AttackBlock/Attack-Level-3.asset @@ -12,4 +12,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: db8f30e5213a1754699f4eda49cb3e63, type: 3} m_Name: Attack-Level-3 m_EditorClassIdentifier: - prefabs: [] + prefabs: + - {fileID: 153724040464013533, guid: 25090bb6da3a3a144bc7308bf8ee1ddc, type: 3} + - {fileID: 6932241698995909476, guid: 3b92359e52c9ec14fb0ac66d88680564, type: 3} + - {fileID: 8811406908067387120, guid: 18ddbc2ec71e5324fb123e1871dedf83, type: 3} + - {fileID: 7680806552874981335, guid: 296457b13a26f8b47bc75a00d0e63ab0, type: 3} + - {fileID: 3771963018917625986, guid: df95264657c12d044840f07604f64b05, type: 3} + - {fileID: 4632827343611451248, guid: 45098a2d9f390084ca3dbc5be1a37fc2, type: 3} + - {fileID: 6227114820474435122, guid: a58ef869c9f73a84487cc8c6c5868768, type: 3} + - {fileID: 4683095661607992907, guid: 9e439c29550618c43b0f467eff89d778, type: 3} diff --git a/Assets/Prefeb/AttackBlock/Attack-Level-4.asset b/Assets/Prefeb/AttackBlock/Attack-Level-4.asset index 6dd6d0c..c1120b7 100644 --- a/Assets/Prefeb/AttackBlock/Attack-Level-4.asset +++ b/Assets/Prefeb/AttackBlock/Attack-Level-4.asset @@ -12,4 +12,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: db8f30e5213a1754699f4eda49cb3e63, type: 3} m_Name: Attack-Level-4 m_EditorClassIdentifier: - prefabs: [] + prefabs: + - {fileID: 2868400889033167268, guid: 130c5826bf21ac34a9d2f73b0c433f97, type: 3} + - {fileID: 7064833557264840747, guid: 2e0c5cd751a45c44b93cfa8f5453b963, type: 3} + - {fileID: 2980891294243248750, guid: 96d5fe65469ff004089f43bb0fc1b9ae, type: 3} + - {fileID: 8037128401047184452, guid: 71224e1986254924b8b5a938cb66e2e3, type: 3} + - {fileID: 4621523416105491377, guid: f1559bd3904dd53458e744a59ed0cb69, type: 3} + - {fileID: 9133506841816092732, guid: 8fa6fc423c8822749bf4f72a33fba696, type: 3} + - {fileID: 1784126616450114382, guid: 0c7ec1d1c61772c45931a8207ff74a63, type: 3} + - {fileID: 7781315202289332697, guid: 33bbd85803525814c8343995827a23df, type: 3} diff --git a/Assets/Prefeb/AttackBlock/Attack-Level-5.asset b/Assets/Prefeb/AttackBlock/Attack-Level-5.asset index ef67946..e22991f 100644 --- a/Assets/Prefeb/AttackBlock/Attack-Level-5.asset +++ b/Assets/Prefeb/AttackBlock/Attack-Level-5.asset @@ -12,4 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: db8f30e5213a1754699f4eda49cb3e63, type: 3} m_Name: Attack-Level-5 m_EditorClassIdentifier: - prefabs: [] + prefabs: + - {fileID: 4889017667857126960, guid: d79eeedf6ed13d74f84d4153e2a2b284, type: 3} + - {fileID: 6726598211612887349, guid: c5f7939eed90cce4e8e67d73226c8fb2, type: 3} + - {fileID: 2974204549381235631, guid: 4994a976d1a7f2a4a8a77f9475486203, type: 3} diff --git a/Assets/Prefeb/ProbabilityPanel/SingleLevelProbabilityPanel.prefab b/Assets/Prefeb/ProbabilityPanel/SingleLevelProbabilityPanel.prefab index 9db5f63..935050b 100644 --- a/Assets/Prefeb/ProbabilityPanel/SingleLevelProbabilityPanel.prefab +++ b/Assets/Prefeb/ProbabilityPanel/SingleLevelProbabilityPanel.prefab @@ -476,14 +476,14 @@ MonoBehaviour: m_VerticalScrollbarEventHandler: {fileID: 0} m_LayoutGroup: {fileID: 0} m_ScrollSensitivity: 1 - m_ContentType: 0 + m_ContentType: 3 m_InputType: 0 m_AsteriskChar: 42 - m_KeyboardType: 0 + m_KeyboardType: 2 m_LineType: 0 m_HideMobileInput: 0 m_HideSoftKeyboard: 0 - m_CharacterValidation: 0 + m_CharacterValidation: 3 m_RegexValue: m_GlobalPointSize: 14 m_CharacterLimit: 0 @@ -1067,6 +1067,7 @@ MonoBehaviour: lockImg: {fileID: 5717613260432307835} unlockImg: {fileID: 5816262599943080368} probabilitySlider: {fileID: 2237638637685423040} + probabilityValue: 0 --- !u!1 &6883838559566756852 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/TargetLevelProbabilityPanel.cs b/Assets/TargetLevelProbabilityPanel.cs index ea4be15..0a9b4b3 100644 --- a/Assets/TargetLevelProbabilityPanel.cs +++ b/Assets/TargetLevelProbabilityPanel.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using TMPro; @@ -36,7 +37,8 @@ public void IntializePanels(int levelNum, string titleName) singleLevelPanels.Add(singleLevelPanelsObjs[i].GetComponent()); singleLevelPanels[i].InitializeLevelProbabilityPanel(i, i == levelNum - 1 ? lastLevelProbability : averageProbability); //add onValueChanged event to slider and input field - singleLevelPanels[i].probabilitySlider.onValueChanged.AddListener((value) => OnSliderValueChange(value, tempIndex)); + singleLevelPanels[i].probabilitySlider.onValueChanged.AddListener((value) => OnProbabilityValueChange(value, tempIndex)); + singleLevelPanels[i].inputField.onEndEdit.AddListener((value) => OnProbabilityValueChange(value, tempIndex)); } panelNum = levelNum; } @@ -65,8 +67,30 @@ private void AddEventTrigger(GameObject gameObject, EventTriggerType triggerType /// /// change to this value /// changed panel index - private void OnSliderValueChange(float value, int exceptedIndex) + private void OnProbabilityValueChange(T value, int exceptedIndex) { + float changedValue = 0f; + switch (value) + { + case float floatValue: + changedValue = floatValue; + break; + case string stringValue: + changedValue = float.Parse(stringValue); + // limit the value between 0 and 1 + if(changedValue>1 && changedValue <=100) + { + changedValue /= 100; + }else if(changedValue>100) + { + changedValue = 1; + } + break; + default: + Debug.LogError("Invalid value type!"); + throw new ArgumentException("Unsupported value type"); + } + Debug.Log(value); float newTotalValue = 0; // new total probability value without locked panel int unlockedPanelNum = 0; int remainCorrectionNum = panelNum; @@ -82,7 +106,7 @@ private void OnSliderValueChange(float value, int exceptedIndex) if (singleLevelPanels[i].UnLocked) { unlockedPanelNum++; - newTotalValue += (i == exceptedIndex ? value : singleLevelPanels[i].ProbabilityValue); + newTotalValue += (i == exceptedIndex ? changedValue : singleLevelPanels[i].ProbabilityValue); } else { @@ -114,7 +138,7 @@ private void OnSliderValueChange(float value, int exceptedIndex) while (remainCorrectionNum > 0) { iterationCount++; - (correctionValues, remainCorrectionNum) = reCalculateCorrectionValues(correctionValues, exceptedIndex, value, extraValue, maxLimitValue); + (correctionValues, remainCorrectionNum) = reCalculateCorrectionValues(correctionValues, exceptedIndex, changedValue, extraValue, maxLimitValue); // protect the infinite loop if (iterationCount >= 100) { @@ -136,7 +160,7 @@ private void enableSliderListener() for (int i = 0; i < panelNum; i++) { int tempIndex = i; - singleLevelPanels[i].probabilitySlider.onValueChanged.AddListener((value) => OnSliderValueChange(value, tempIndex)); + singleLevelPanels[i].probabilitySlider.onValueChanged.AddListener((value) => OnProbabilityValueChange(value, tempIndex)); } } diff --git a/UserSettings/Layouts/default-2021.dwlt b/UserSettings/Layouts/default-2021.dwlt index d6a9879..cbe23f7 100644 --- a/UserSettings/Layouts/default-2021.dwlt +++ b/UserSettings/Layouts/default-2021.dwlt @@ -14,16 +14,16 @@ MonoBehaviour: m_EditorClassIdentifier: m_PixelRect: serializedVersion: 2 - x: 65 - y: 43 - width: 1855 + x: 1926 + y: 142 + width: 1792 height: 1037 m_ShowMode: 4 m_Title: Hierarchy m_RootView: {fileID: 2} m_MinSize: {x: 875, y: 300} m_MaxSize: {x: 10000, y: 10000} - m_Maximized: 1 + m_Maximized: 0 --- !u!114 &2 MonoBehaviour: m_ObjectHideFlags: 52 @@ -44,7 +44,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1855 + width: 1792 height: 1037 m_MinSize: {x: 875, y: 300} m_MaxSize: {x: 10000, y: 10000} @@ -69,7 +69,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1855 + width: 1792 height: 30 m_MinSize: {x: 0, y: 0} m_MaxSize: {x: 0, y: 0} @@ -91,7 +91,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 1017 - width: 1855 + width: 1792 height: 20 m_MinSize: {x: 0, y: 0} m_MaxSize: {x: 0, y: 0} @@ -115,12 +115,12 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 30 - width: 1855 + width: 1792 height: 987 m_MinSize: {x: 300, y: 200} m_MaxSize: {x: 24288, y: 16192} vertical: 0 - controlID: 126 + controlID: 92 --- !u!114 &6 MonoBehaviour: m_ObjectHideFlags: 52 @@ -140,12 +140,12 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1258 + width: 1184 height: 987 m_MinSize: {x: 100, y: 200} m_MaxSize: {x: 8096, y: 16192} vertical: 1 - controlID: 127 + controlID: 93 --- !u!114 &7 MonoBehaviour: m_ObjectHideFlags: 52 @@ -163,7 +163,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1258 + width: 1184 height: 612 m_MinSize: {x: 201, y: 221} m_MaxSize: {x: 4001, y: 4021} @@ -190,7 +190,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 612 - width: 1258 + width: 1184 height: 375 m_MinSize: {x: 231, y: 271} m_MaxSize: {x: 10001, y: 10021} @@ -217,14 +217,14 @@ MonoBehaviour: - {fileID: 11} m_Position: serializedVersion: 2 - x: 1258 + x: 1184 y: 0 - width: 344 + width: 265 height: 987 m_MinSize: {x: 100, y: 200} m_MaxSize: {x: 8096, y: 16192} vertical: 1 - controlID: 54 + controlID: 61 --- !u!114 &10 MonoBehaviour: m_ObjectHideFlags: 52 @@ -242,7 +242,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 344 + width: 265 height: 612 m_MinSize: {x: 202, y: 221} m_MaxSize: {x: 4002, y: 4021} @@ -268,7 +268,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 612 - width: 344 + width: 265 height: 375 m_MinSize: {x: 102, y: 121} m_MaxSize: {x: 4002, y: 4021} @@ -293,9 +293,9 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 1602 + x: 1449 y: 0 - width: 253 + width: 343 height: 987 m_MinSize: {x: 276, y: 71} m_MaxSize: {x: 4001, y: 4021} @@ -324,9 +324,9 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 65 - y: 73 - width: 1257 + x: 1926 + y: 172 + width: 1183 height: 591 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: @@ -564,7 +564,7 @@ MonoBehaviour: m_Position: m_Target: {x: 438.35324, y: 362.60254, z: 0.11418539} speed: 2 - m_Value: {x: 438.35324, y: 362.60254, z: 0.11418539} + m_Value: {x: 176.75958, y: 480.91754, z: 0} m_RenderMode: 0 m_CameraMode: drawMode: 0 @@ -617,7 +617,7 @@ MonoBehaviour: m_Size: m_Target: 528.95575 speed: 2 - m_Value: 528.95575 + m_Value: 144.75821 m_Ortho: m_Target: 1 speed: 2 @@ -635,7 +635,7 @@ MonoBehaviour: m_FarClip: 10000 m_DynamicClip: 1 m_OcclusionCulling: 0 - m_LastSceneViewRotation: {x: -0.08717229, y: 0.89959055, z: -0.21045254, w: -0.3726226} + m_LastSceneViewRotation: {x: -0.25256547, y: -0.3519945, z: 0.09924266, w: -0.89579886} m_LastSceneViewOrtho: 0 m_ReplacementShader: {fileID: 0} m_ReplacementString: @@ -662,10 +662,10 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 73 - y: 81 - width: 1082 - height: 577 + x: 65 + y: 73 + width: 1225 + height: 591 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -676,7 +676,7 @@ MonoBehaviour: m_ShowGizmos: 0 m_TargetDisplay: 0 m_ClearColor: {r: 0, g: 0, b: 0, a: 0} - m_TargetSize: {x: 1082, y: 556} + m_TargetSize: {x: 1225, y: 570} m_TextureFilterMode: 0 m_TextureHideFlags: 61 m_RenderIMGUI: 1 @@ -691,10 +691,10 @@ MonoBehaviour: m_VRangeLocked: 0 hZoomLockedByDefault: 0 vZoomLockedByDefault: 0 - m_HBaseRangeMin: -541 - m_HBaseRangeMax: 541 - m_VBaseRangeMin: -278 - m_VBaseRangeMax: 278 + m_HBaseRangeMin: -612.5 + m_HBaseRangeMax: 612.5 + m_VBaseRangeMin: -285 + m_VBaseRangeMax: 285 m_HAllowExceedBaseRangeMin: 1 m_HAllowExceedBaseRangeMax: 1 m_VAllowExceedBaseRangeMin: 1 @@ -712,23 +712,23 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 21 - width: 1082 - height: 556 + width: 1225 + height: 570 m_Scale: {x: 1, y: 1} - m_Translation: {x: 541, y: 278} + m_Translation: {x: 612.5, y: 285} m_MarginLeft: 0 m_MarginRight: 0 m_MarginTop: 0 m_MarginBottom: 0 m_LastShownAreaInsideMargins: serializedVersion: 2 - x: -541 - y: -278 - width: 1082 - height: 556 + x: -612.5 + y: -285 + width: 1225 + height: 570 m_MinimalGUI: 1 m_defaultScale: 1 - m_LastWindowPixelSize: {x: 1082, y: 577} + m_LastWindowPixelSize: {x: 1225, y: 591} m_ClearInEditMode: 1 m_NoCameraWarning: 1 m_LowResolutionForAspectRatios: 01000000000000000000 @@ -754,9 +754,9 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 65 - y: 685 - width: 1257 + x: 1926 + y: 784 + width: 1183 height: 354 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: @@ -781,7 +781,7 @@ MonoBehaviour: m_ViewMode: 1 m_StartGridSize: 16 m_LastFolders: - - Assets/Prefeb/AttackBlock + - Assets/Prefeb/ProbabilityPanel m_LastFoldersGridSize: 16 m_LastProjectPath: C:\Users\UCUNI\OneDrive\Unity\ML-Agents\Aimbot-ParallelEnv m_LockTracker: @@ -790,7 +790,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: 06ca9a3b m_LastClickedID: 1000000006 - m_ExpandedIDs: 0000000030760000327600003476000036760000387600003a7600003c7600003e76000040760000427600004476000046760000487600004a7600004c7600004e760000507600005276000000ca9a3bffffff7f + m_ExpandedIDs: 0000000030760000327600003476000036760000387600003a7600003c7600003e760000407600004276000046760000487600004a7600004c7600004e76000050760000527600008a76000000ca9a3bffffff7f m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -922,9 +922,9 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1323 - y: 73 - width: 342 + x: 3110 + y: 172 + width: 263 height: 591 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: @@ -979,9 +979,9 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1323 - y: 685 - width: 342 + x: 3110 + y: 784 + width: 263 height: 354 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: @@ -999,7 +999,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6c262c1329a02fa49b5cb4c297106f3f, type: 3} m_Name: m_EditorClassIdentifier: - m_MinSize: {x: 129, y: 28} + m_MinSize: {x: 136, y: 30} m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: ProBuilder @@ -1035,9 +1035,9 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1667 - y: 73 - width: 252 + x: 3375 + y: 172 + width: 342 height: 966 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: