From 57f818d264c6a9fed213f6c4db89e0b0928cd754 Mon Sep 17 00:00:00 2001 From: lujiajian <204551278@qq.com> Date: Fri, 6 Mar 2026 09:09:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Line/LineConnect.cs | 2 +- Assets/Scripts/Line/LineManager.cs | 154 +++++++++--------- .../ProjectBase/UIManager/UIManager.cs | 1 + .../UI/UIPanel/UI_ExperimentChooesPanel.cs | 4 +- Assets/Scripts/UI/UIPanel/UI_RoamingPanel.cs | 1 + Assets/Scripts/UI/UIPanel/UI_TopTipPanel.cs | 9 +- 6 files changed, 91 insertions(+), 80 deletions(-) diff --git a/Assets/Scripts/Line/LineConnect.cs b/Assets/Scripts/Line/LineConnect.cs index 5804aa6..8ca5483 100644 --- a/Assets/Scripts/Line/LineConnect.cs +++ b/Assets/Scripts/Line/LineConnect.cs @@ -73,7 +73,7 @@ public class LineConnect : MonoBehaviour public bool isClick = false; private void OnMouseDown() { - if (!isClick && LineManager.instance.Addtime >= 2) + if (!isClick && LineManager.instance.Addtime >= 4) { isClick = true; Debug.Log(transform.name); diff --git a/Assets/Scripts/Line/LineManager.cs b/Assets/Scripts/Line/LineManager.cs index 0422c1d..a215000 100644 --- a/Assets/Scripts/Line/LineManager.cs +++ b/Assets/Scripts/Line/LineManager.cs @@ -7,6 +7,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Reflection; using TMPro; using Unity.VisualScripting; using UnityEditor; @@ -80,16 +81,6 @@ public class LineManager : SerializedMonoBehaviour if (PlayerPrefs.GetString("LineData") != "") { int index = PlayerPrefs.GetInt("classnum"); - if (UI_ExperimentChooesPanel.instance != null) - { - for (int i = 0; i < UI_ExperimentChooesPanel.instance.SubjectTog.Count; i++) - { - if (UI_ExperimentChooesPanel.instance.SubjectTog[i].name.Replace("-", "") == (index.ToString())) - { - UI_ExperimentChooesPanel.instance.SubjectTog[i].isOn = true; - } - } - } Models = new List(); Highlights = new List(); Highlights_Backup = new List(); @@ -108,6 +99,7 @@ public class LineManager : SerializedMonoBehaviour } } } + Debug.Log(" lineData.Modelname.Count;" + lineData.Modelname.Count); allline = lineData.Modelname.Count; for (int j = 0; j < lineData.Modelname.Count; j++) { @@ -127,16 +119,27 @@ public class LineManager : SerializedMonoBehaviour { Highlights_Backup[i].highlighted = false; } - LineName = Highlights[0].GetComponent().interfaceType.ToString(); - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + //LineName = Highlights[0].GetComponent().interfaceType.ToString(); + //UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); Highlights[0].highlighted = true; Highlights[0].GetComponent().enabled = true; } + if (UI_ExperimentChooesPanel.instance != null) + { + for (int i = 0; i < UI_ExperimentChooesPanel.instance.SubjectTog.Count; i++) + { + if (UI_ExperimentChooesPanel.instance.SubjectTog[i].name.Replace("-", "") == (PlayerPrefs.GetInt("classnum").ToString())) + { + UI_ExperimentChooesPanel.instance.SubjectTog[i].SetIsOnWithoutNotify(true); + } + } + } + Initialization(PlayerPrefs.GetInt("classnum")); #endregion } void Start() { - Initialization(); + //ResetLine(); } /// @@ -154,7 +157,7 @@ public class LineManager : SerializedMonoBehaviour } allline = 0; Highlights_Backup.ForEach((x) => { x.highlighted = false; }); - HighlightInit(""); + HighlightInit("", ExperimentNumber); for (int i = 0; i < Highlights.Count; i++) { if (i != 0) @@ -174,70 +177,20 @@ public class LineManager : SerializedMonoBehaviour isshow = false; LightPanel.highlighted = true; Devices.highlighted = true; - switch (ExperimentNumber) - { - case 511: - Laboratorycourse = "比例(P)环节,K=1"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[0]; - break; - case 512: - Laboratorycourse = "比例(P)环节,K=2"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[1]; - break; - case 521: - Laboratorycourse = "积分(I)环节,T=1S"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[2]; - break; - case 522: - Laboratorycourse = "积分(I)环节,T=0.1S"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[3]; - break; - case 531: - Laboratorycourse = "比例积分(PI)环节,T=1S"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[2]; - break; - case 532: - Laboratorycourse = "比例积分(PI)环节,T=0.1S"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[5]; - break; - case 541: - Laboratorycourse = "比例微分(PD)环节,T=1S"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[5]; - break; - case 542: - Laboratorycourse = "比例微分(PD)环节,T=2S"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[5]; - break; - case 551: - Laboratorycourse = "惯性环节,T=1S"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[5]; - break; - case 552: - Laboratorycourse = "惯性环节,T=2S"; - UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); - ComputerPanel.sprite = Experimentalresults[5]; - break; - } } bool isshow; void Update() { + //Debug.Log("isInit:" + isInit); //Debug.Log("面板是否显示:" + Bootstrap.Instance.uiManager.GetPanel().gameObject.activeInHierarchy); if (Input.GetMouseButtonDown(2)) { point1 = null; point2 = null; PlayerPrefs.SetString("LineData", ""); + PlayerPrefs.SetInt("classnum", 511); } + Debug.Log(allline); if (allline >= Models.Count && !isshow && !Bootstrap.Instance.uiManager.GetPanel().gameObject.activeInHierarchy) { isshow = true; @@ -265,15 +218,12 @@ public class LineManager : SerializedMonoBehaviour //先重置高亮,再重置模型,否则初始化无法正确显示高亮 Highlights = highlightsdic[indext].ToList(); Highlights_Backup = highlightsdic[indext].ToList(); - Initialization(indext); Models.ForEach((x) => { x.SetActive(false); }); Models = Modeldic[indext].ToList(); PlayerPrefs.SetInt("classnum", indext); - if (!isInit)//初始化不清空数据 - { - PlayerPrefs.SetString("LineData", ""); - } - isInit = false; + PlayerPrefs.SetString("LineData", ""); + Initialization(indext); + //isInit = false; } } /// @@ -476,7 +426,7 @@ public class LineManager : SerializedMonoBehaviour /// /// 高亮初始化 /// - private void HighlightInit(string point) + private void HighlightInit(string point, int classnum = 0) { for (int i = 0; i < Highlights.Count; i++) { @@ -500,6 +450,62 @@ public class LineManager : SerializedMonoBehaviour (panel) => { panel.Init("提示:" + "当前实验是比例(P)环节,K=1", ",请点击" + LineName + "。"); + if (classnum != 0) + { + switch (classnum) + { + case 511: + Laboratorycourse = "比例(P)环节,K=1"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[0]; + break; + case 512: + Laboratorycourse = "比例(P)环节,K=2"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[1]; + break; + case 521: + Laboratorycourse = "积分(I)环节,T=1S"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[2]; + break; + case 522: + Laboratorycourse = "积分(I)环节,T=0.1S"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[3]; + break; + case 531: + Laboratorycourse = "比例积分(PI)环节,T=1S"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[2]; + break; + case 532: + Laboratorycourse = "比例积分(PI)环节,T=0.1S"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[5]; + break; + case 541: + Laboratorycourse = "比例微分(PD)环节,T=1S"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[5]; + break; + case 542: + Laboratorycourse = "比例微分(PD)环节,T=2S"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[5]; + break; + case 551: + Laboratorycourse = "惯性环节,T=1S"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[5]; + break; + case 552: + Laboratorycourse = "惯性环节,T=2S"; + UI_TopTipPanel.instance.Init("提示:" + "当前实验是" + Laboratorycourse, ",请点击" + LineName + "。"); + ComputerPanel.sprite = Experimentalresults[5]; + break; + } + } }); } } diff --git a/Assets/Scripts/Project/ProjectBase/UIManager/UIManager.cs b/Assets/Scripts/Project/ProjectBase/UIManager/UIManager.cs index 8dffd80..d06de25 100644 --- a/Assets/Scripts/Project/ProjectBase/UIManager/UIManager.cs +++ b/Assets/Scripts/Project/ProjectBase/UIManager/UIManager.cs @@ -107,6 +107,7 @@ public class UIManager T panel = panelObj.GetComponent(); panel.ShowMe(); action?.Invoke(panel); + Debug.Log("panelName"+panelName); panelDic.Add(panelName, panel); }); } diff --git a/Assets/Scripts/UI/UIPanel/UI_ExperimentChooesPanel.cs b/Assets/Scripts/UI/UIPanel/UI_ExperimentChooesPanel.cs index ae87de1..1679e2f 100644 --- a/Assets/Scripts/UI/UIPanel/UI_ExperimentChooesPanel.cs +++ b/Assets/Scripts/UI/UIPanel/UI_ExperimentChooesPanel.cs @@ -20,7 +20,7 @@ public class UI_ExperimentChooesPanel : BasePanel public void OnInit() { - + } public override void ShowMe() { @@ -35,7 +35,7 @@ public class UI_ExperimentChooesPanel : BasePanel protected override void OnChangeToggle(string btnPath, bool isOn) { base.OnClick(btnPath); - if (isOn) + if (isOn && LineManager.instance != null) { Debug.Log("当前点击的科目是" + btnPath); switch (btnPath) diff --git a/Assets/Scripts/UI/UIPanel/UI_RoamingPanel.cs b/Assets/Scripts/UI/UIPanel/UI_RoamingPanel.cs index d82e5a2..7ca5be8 100644 --- a/Assets/Scripts/UI/UIPanel/UI_RoamingPanel.cs +++ b/Assets/Scripts/UI/UIPanel/UI_RoamingPanel.cs @@ -64,6 +64,7 @@ public class UI_RoamingPanel : BasePanel yield return new WaitForSeconds(3.6f); LineManager.instance.ResetLine(); Bootstrap.Instance.uiManager.HidePanel(); + } /// diff --git a/Assets/Scripts/UI/UIPanel/UI_TopTipPanel.cs b/Assets/Scripts/UI/UIPanel/UI_TopTipPanel.cs index 83d2c1a..9300ebc 100644 --- a/Assets/Scripts/UI/UIPanel/UI_TopTipPanel.cs +++ b/Assets/Scripts/UI/UIPanel/UI_TopTipPanel.cs @@ -2,7 +2,9 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; using TMPro; +using Unity.VisualScripting; using UnityEngine; +using UnityEngine.Events; using UnityEngine.UI; public class UI_TopTipPanel : BasePanel @@ -11,9 +13,10 @@ public class UI_TopTipPanel : BasePanel public TextMeshProUGUI text_Content; public TextMeshProUGUI text_Title; public static UI_TopTipPanel instance; - private void Awake() + protected override void Awake() { instance = this; + } public void Init(string title, string content) { @@ -21,10 +24,10 @@ public class UI_TopTipPanel : BasePanel //text_Content = GetControl("Text_Content"); //bg = GetControl("UI_TopTipPanelBG"); text_Title.text = "" + title + ""; - text_Content.text = "" + content + ""; + text_Content.text = "" + content + ""; TextMeshProUGUI tempText = text_Title.preferredWidth > text_Content.preferredWidth ? text_Title : text_Content; AdjustImageWidth(tempText, bg.rectTransform, 30, 21); - // LineManager.instance.ResetLine(); + // LineManager.instance.ResetLine(); } /// /// 面板消失