4.8上午提交

This commit is contained in:
taosuqi 2025-04-08 09:11:04 +08:00
parent d7450374e4
commit 76d78f7ae3
5 changed files with 84 additions and 43 deletions

View File

@ -831,7 +831,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0.0002783385}
m_AnchoredPosition: {x: 0, y: 0.00022947599}
m_SizeDelta: {x: 0, y: 300}
m_Pivot: {x: 0, y: 1}
--- !u!1 &5648230691007625910
@ -1162,10 +1162,10 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 54654654654654654465
m_text: "\u76F8\u5173\u4ECB\u7ECD"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 1c4004df1d65ff944b6e23e3af757df7, type: 2}
m_sharedMaterial: {fileID: 1751944718996602668, guid: 1c4004df1d65ff944b6e23e3af757df7, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []

View File

@ -386,9 +386,9 @@ RectTransform:
m_Father: {fileID: 5924775712395334843}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 766, y: -412}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1332, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &6001528603228556391
@ -1582,9 +1582,9 @@ RectTransform:
m_Father: {fileID: 5924775712395334843}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 766, y: -300}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1332, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &6086586699102765214
@ -1670,9 +1670,9 @@ RectTransform:
m_Father: {fileID: 5924775712395334843}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 766, y: -524}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1332, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &5653636613290556819
@ -1758,9 +1758,9 @@ RectTransform:
m_Father: {fileID: 5924775712395334843}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 766, y: -636}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1332, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1429247267648985812

View File

@ -658,9 +658,9 @@ RectTransform:
m_Father: {fileID: 5924775712395334843}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 804, y: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1608, y: 940}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &6109062945893642881

View File

@ -16,9 +16,6 @@ public class Const
}
[Serializable]
public class ChooseItem
{
@ -60,6 +57,10 @@ public class ChooseItem
/// 答案
/// </summary>
public string answer;
/// <summary>
/// 当前选择的
/// </summary>
public string CurrentOptions;
}

View File

@ -27,6 +27,7 @@ public class UI_ExamPanel : BasePanel
public TextMeshProUGUI TopicType_Text;
public TextMeshProUGUI[] topicLabel;//ÌâĿѡÏî
private List<Toggle> questionToggles = new List<Toggle>(); // 动态生成的题目Toggle列表
private int curIndex;
protected override void Awake()
{
@ -37,37 +38,76 @@ public class UI_ExamPanel : BasePanel
{
var item = Instantiate(UI_Topicitem, Rigcontent);
item.Init(tmxh.topiceNumber);
var ToogleText = item.GetControl<Text>("Label");
Toggle toggle = item.GetControl<Toggle>("Toggle");
int currentIndex = int.Parse(tmxh.topiceNumber) - 1;
toggle.group = ToggleGroup;
questionToggles.Add(toggle);
int currentIndex = index;
toggle.onValueChanged.RemoveAllListeners();
toggle.onValueChanged.AddListener((ison) =>
{
if (ison)
{
Debug.Log($"Toggle选中:{currentIndex}");
fun(currentIndex);
}
}
});
// 如果是第一个Toggle设置为选中状态
Debug.Log(toggle.name);
if (index == 0)
{
toggle.isOn = true;
}
index++; // 更新索引
if (index == 0) toggle.isOn = true;
index++;
ToggleGroup.allowSwitchOff = false;
UpdateQuestionUI();
}
// 确保 ToggleGroup 状态正确
ToggleGroup.allowSwitchOff = false;
ToggleGroup.SetAllTogglesOff();
//if (Rigcontent.childCount > 0)
//{
// Rigcontent.GetChild(0).GetComponent<Toggle>().isOn = true;
//}
//StartCoroutine(SetFirstToggleNextFrame());
//// 确保 ToggleGroup 状态正确
//ToggleGroup.allowSwitchOff = false;
//ToggleGroup.SetAllTogglesOff();
//UpdateQuestionUI();
}
// 更新题目UI
private void UpdateQuestionUI()
{
if (curIndex < 0 || curIndex >= Root.choose.Count) return;
var currentQuestion = Root.choose[curIndex];
// 更新题目类型
bool isJudgment = currentQuestion.topicetype == "1";
topicetype.text = isJudgment ? "[判断题]" : "[选择题]";
TopicType_Text.text = isJudgment ? "判断题" : "选择题";
// 显示/隐藏选项
toggles[2].gameObject.SetActive(!isJudgment);
toggles[3].gameObject.SetActive(!isJudgment);
// 更新题目文本和选项
topicText.text = currentQuestion.topiceName;
topicLabel[0].text = currentQuestion.chooseA;
topicLabel[1].text = currentQuestion.chooseB;
topicLabel[2].text = currentQuestion.chooseC;
topicLabel[3].text = currentQuestion.ChooseD;
// 更新按钮状态
PreviousQuestion_Btn.gameObject.SetActive(curIndex > 0);
NextQuestion_Btn.gameObject.SetActive(curIndex < Root.choose.Count - 1);
// 选中当前题目的Toggle
if (questionToggles.Count > curIndex)
{
questionToggles[curIndex].isOn = true;
}
}
private void SwitchQuestion(int offset)
{
int newIndex = curIndex + offset;
if (newIndex < 0 || newIndex >= questionToggles.Count) return;
curIndex = newIndex;
questionToggles[curIndex].isOn = true;
UpdateQuestionUI();
}
private void fun(int index_)
{
Debug.Log(index_);
@ -145,10 +185,10 @@ public class UI_ExamPanel : BasePanel
break;
case "PreviousQuestion_Btn":
SwitchQuestion(-1);
break;
case "NextQuestion_Btn":
SwitchQuestion(1);
break;
}
}