From 4a1837a740bd3983b07aec2cae6316d448c01380 Mon Sep 17 00:00:00 2001 From: lq <3298408835@qq.com> Date: Mon, 9 Dec 2024 09:53:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=89=A7=E6=9C=AC=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Scenes/Schedule_03.unity | 11 +--- .../Script/UI/PanelUI/SelectScenePanel.cs | 51 +++++++++++++++---- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/xiaofang/Assets/Scenes/Schedule_03.unity b/xiaofang/Assets/Scenes/Schedule_03.unity index 181f3449..c11dc96c 100644 --- a/xiaofang/Assets/Scenes/Schedule_03.unity +++ b/xiaofang/Assets/Scenes/Schedule_03.unity @@ -9026,7 +9026,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &1600693806 RectTransform: m_ObjectHideFlags: 0 @@ -15738,14 +15738,7 @@ MonoBehaviour: continueBtn: {fileID: 7468736065153534603} submitBtn: {fileID: 7468736064182248777} scenetoggleList: [] - schooltoggleList: - - {fileID: 7468736064927213712} - - {fileID: 7468736064421981271} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} + schooltoggleList: [] eventToggleList: [] evnetsceneList: [] toggleGroup: {fileID: 0} diff --git a/xiaofang/Assets/Script/UI/PanelUI/SelectScenePanel.cs b/xiaofang/Assets/Script/UI/PanelUI/SelectScenePanel.cs index 0fffaee4..5fea9bb9 100644 --- a/xiaofang/Assets/Script/UI/PanelUI/SelectScenePanel.cs +++ b/xiaofang/Assets/Script/UI/PanelUI/SelectScenePanel.cs @@ -137,7 +137,6 @@ public class SelectScenePanel : MonoBehaviour item.schoolName.text = "南山中学"; item.schoolId = i; Toggle toggle = slot.GetComponent(); - if (toggle != null) { toggle.group = schoolGroup; @@ -154,7 +153,7 @@ public class SelectScenePanel : MonoBehaviour { if (eventData.Key == eventId) { - Debug.Log("<<<<<<<<<<<<<<<<(incidentPrefab, incidentList); IncidentInfo item = slot.GetComponent(); item.incidentText.text = eventData.Value.Note; @@ -166,6 +165,7 @@ public class SelectScenePanel : MonoBehaviour // 将 Toggle 添加到 ToggleGroup 中 toggle.group = incidentGroup; toggle.isOn = false; + eventToggleList.Add(toggle); incidentInfos.Add(item); if (incidentInfos.Count > 1) { @@ -203,8 +203,6 @@ public class SelectScenePanel : MonoBehaviour } } }); - - } } } @@ -222,7 +220,7 @@ public class SelectScenePanel : MonoBehaviour // 遍历每个分隔出来的 id foreach (string incidentIdStr in incidentIds) { - Debug.Log("incidentIdStr" + incidentIdStr); + //Debug.Log("incidentIdStr" + incidentIdStr); // 转换字符串为 int 类型 if (int.TryParse(incidentIdStr, out int incidentId)) { @@ -266,7 +264,7 @@ public class SelectScenePanel : MonoBehaviour EventData eventData = jsonReader.GetEvenById(this.eventId); foreach (string disasterLocation in incidentIds2) { - Debug.Log("disasterLocation>>>>>>>"+ disasterLocation); + //Debug.Log("disasterLocation>>>>>>>"+ disasterLocation); InstantiateIncidentPrefab(int.Parse(disasterLocation)); OnRandomEventClick(); } @@ -421,6 +419,7 @@ public class SelectScenePanel : MonoBehaviour SetDataPanelInfo(); this.gameObject.SetActive(false); panel.gameObject.SetActive(true); + DisableUIInteraction(); } //关闭按钮 @@ -455,7 +454,7 @@ public class SelectScenePanel : MonoBehaviour //通过判断Toggle的IsOn是否被打开来判断继续按钮是否置灰 public void IsClick() { - bool anyToggleSelected = false; + bool anyToggleSelected = true; // 检查场景选择 foreach (Toggle toggle in scenetoggleList) @@ -483,13 +482,12 @@ public class SelectScenePanel : MonoBehaviour bool anyToggleSelected = false; bool anyeventSelected = false; bool isOk = false; - Debug.Log("evnetsceneList>>>>"+ evnetsceneList.Count()); + //Debug.Log("evnetsceneList>>>>"+ evnetsceneList.Count()); // 检查场景选择 foreach (Toggle toggle in evnetsceneList) { if (toggle.isOn) { - anyToggleSelected = true; break; // 如果有一个场景 Toggle 被选中,停止检查 } @@ -504,6 +502,7 @@ public class SelectScenePanel : MonoBehaviour break; // 如果有一个场景 Toggle 被选中,停止检查 } } + Debug.Log(submitBtn != null && anyToggleSelected == true && anyeventSelected == true); // 根据是否有 Toggle 被选中,设置 ContinueBtn 是否可交互 if (submitBtn != null && anyToggleSelected == true&& anyeventSelected==true) { @@ -596,4 +595,38 @@ public class SelectScenePanel : MonoBehaviour datePanel.SchoolText.text = sceneName; datePanel.PlaceText.text = idcidentName; } + + //按钮禁用 + public void DisableUIInteraction() + { + // 禁用场景选择中的所有Toggle按钮 + foreach (Toggle toggle in scenetoggleList) + { + toggle.interactable = false; // 设置Toggle为不可交互 + } + Debug.Log("schooltoggleList>>>>>>>>>>"+ schooltoggleList.Count); + // 禁用学校选择中的所有Toggle按钮 + foreach (Toggle toggle in schooltoggleList) + { + toggle.interactable = false; + } + + // 禁用事件选择中的所有Toggle按钮 + foreach (Toggle toggle in eventToggleList) + { + toggle.interactable = false; + } + + // 禁用事件场景选择中的所有Toggle按钮 + foreach (Toggle toggle in evnetsceneList) + { + toggle.interactable = false; + } + + // 禁用继续按钮 + continueBtn.interactable = false; + + // 禁用提交按钮 + submitBtn.interactable = false; + } } \ No newline at end of file