选择演练未选中按钮的禁用
This commit is contained in:
parent
f3478cb879
commit
811a4c3512
26436
xiaofang/Assets/Scenes/GLscene.unity
Normal file
26436
xiaofang/Assets/Scenes/GLscene.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
xiaofang/Assets/Scenes/GLscene.unity.meta
Normal file
7
xiaofang/Assets/Scenes/GLscene.unity.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a33547b8643ef145b58d29667934c41
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1830,7 +1830,6 @@ MonoBehaviour:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
schooltoggleList:
|
||||
- {fileID: 1757980599}
|
||||
- {fileID: 116351856}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user