This commit is contained in:
huyulong 2024-11-29 15:13:50 +08:00
commit c24fd38f6c
4 changed files with 26530 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4a33547b8643ef145b58d29667934c41
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1830,7 +1830,6 @@ MonoBehaviour:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
schooltoggleList:
- {fileID: 1757980599}
- {fileID: 116351856}

View File

@ -30,7 +30,7 @@ public class SelectScenePanel : MonoBehaviour
public Toggle[] schooltoggleList;
public Toggle[] eventToggleList;
public ToggleGroup toggleGroup;
[Header("数据")]
public int schoolId;
public string schoolName;
@ -47,7 +47,12 @@ public class SelectScenePanel : MonoBehaviour
InstantiateScenePrefab();
InstantiateSchoolPrefab();
InstantiateEventPrefab();
SetEventToggleOpenorClose(eventInfoList);
continueBtn.onClick.AddListener(OnClickContinueBtn);
SetFirstChoise(toggleList);
SetToggleOpenorClose(sceneItemList);//未购买无法选择
SetScloolToggleOpenorClose(schoolInfoList);
}
// Update is called once per frame
@ -63,6 +68,9 @@ public class SelectScenePanel : MonoBehaviour
{
GameObject slot = GameObject.Instantiate<GameObject>(scenePrefab, sceneList);
SceneItem item = slot.GetComponent<SceneItem>();
item.sceneName.text = "场景" + i;
if (item.IsOpen)
{
@ -220,7 +228,7 @@ public class SelectScenePanel : MonoBehaviour
}
// 选中随机事件
if (eventToggleList[randomIndex] != null)
if (eventToggleList[randomIndex] != null&& eventToggleList[randomIndex].GetComponent<EventInfo>().isOpen!=false)
{
eventToggleList[randomIndex].isOn = true;
this.eventName = eventInfoList[randomIndex].eventName.text; // 设置随机选择的事件名称
@ -295,7 +303,7 @@ public class SelectScenePanel : MonoBehaviour
// //根据是否有 Toggle 被选中,设置 ContinueBtn 是否可交互
if (continueBtn != null)
{
Debug.Log(anyToggleSelected);
//Debug.Log(anyToggleSelected);
continueBtn.interactable = anyToggleSelected; // 如果有选中的 Toggle继续按钮可交互否则不可交互
}
else
@ -303,4 +311,80 @@ public class SelectScenePanel : MonoBehaviour
Debug.LogError("ContinueBtn 按钮组件未找到!");
}
}
public void SetFirstChoise(Toggle[] toggles)//默认选择第一个Toggle
{
// 获取ToggleGroup中的所有Toggle
// 如果有Toggle则选中第一个
if (toggles.Length > 0)
{
toggles[0].isOn = true;
}
}
//场景toggle
public void SetToggleOpenorClose(List<SceneItem> sceneItems)
{
foreach (SceneItem item in sceneItems)
{
if (item.IsOpen==false)
{
item.GetComponent<Toggle>().interactable = false;
if (item.GetComponent<Toggle>().isOn)
{
item.GetComponent<Toggle>().isOn = false;
}
}
else
{
item.GetComponent<Toggle>().interactable = true;
}
}
}
public void SetScloolToggleOpenorClose(List<SchoolInfo> sceneItems)
{
foreach (SchoolInfo item in sceneItems)
{
if (item.isOpen == false)
{
item.GetComponent<Toggle>().interactable = false;
if (item.GetComponent<Toggle>().isOn)
{
item.GetComponent<Toggle>().isOn = false;
}
}
else
{
item.GetComponent<Toggle>().interactable = true;
}
}
}
public void SetEventToggleOpenorClose(List<EventInfo> sceneItems)
{
foreach (EventInfo item in sceneItems)
{
if (item.isOpen == false)
{
item.GetComponent<Toggle>().interactable = false;
if (item.GetComponent<Toggle>().isOn)
{
item.GetComponent<Toggle>().isOn = false;
}
}
else
{
item.GetComponent<Toggle>().interactable = true;
}
}
}
}