选择剧本更改

This commit is contained in:
lq 2024-12-09 09:53:48 +08:00
parent 39920f011c
commit 4a1837a740
2 changed files with 44 additions and 18 deletions

View File

@ -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}

View File

@ -137,7 +137,6 @@ public class SelectScenePanel : MonoBehaviour
item.schoolName.text = "南山中学";
item.schoolId = i;
Toggle toggle = slot.GetComponent<Toggle>();
if (toggle != null)
{
toggle.group = schoolGroup;
@ -154,7 +153,7 @@ public class SelectScenePanel : MonoBehaviour
{
if (eventData.Key == eventId)
{
Debug.Log("<<<<<<<<<<<<<<<<<eventId" + eventData.Key);
//Debug.Log("<<<<<<<<<<<<<<<<<eventId" + eventData.Key);
GameObject slot = GameObject.Instantiate<GameObject>(incidentPrefab, incidentList);
IncidentInfo item = slot.GetComponent<IncidentInfo>();
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;
}
}