显示Bug修改

This commit is contained in:
lq 2024-12-24 23:00:40 +08:00
parent 1b6e787ec6
commit 6d2c116c62
8 changed files with 131 additions and 66 deletions

View File

@ -773,14 +773,14 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_Color: {r: 0.335849, g: 0.316205, b: 0.316205, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 04a1edbf9a644554c87e0dfdce72653e, type: 3}
m_Sprite: {fileID: 21300000, guid: 95b33b62057b969459448a188c934119, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
@ -967,6 +967,18 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 618256462}
m_TargetAssemblyTypeName: Panel, Assembly-CSharp
m_MethodName: SetTitleText
m_Mode: 2
m_Arguments:
m_ObjectArgument: {fileID: 2020842121}
m_ObjectArgumentAssemblyTypeName: UnityEngine.UI.Text, UnityEngine.UI
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_IsOn: 0
--- !u!114 &361203554
MonoBehaviour:
@ -1247,6 +1259,18 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 618256462}
m_TargetAssemblyTypeName: Panel, Assembly-CSharp
m_MethodName: SetTitleText
m_Mode: 2
m_Arguments:
m_ObjectArgument: {fileID: 1103804287}
m_ObjectArgumentAssemblyTypeName: UnityEngine.UI.Text, UnityEngine.UI
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_IsOn: 0
--- !u!114 &452024859
MonoBehaviour:
@ -1462,7 +1486,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 521824338218413953, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: -20.381073
objectReference: {fileID: 0}
- target: {fileID: 521824338318890041, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_AnchorMax.x
@ -1474,7 +1498,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 521824338318890041, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: -20.381073
objectReference: {fileID: 0}
- target: {fileID: 1373529960062900723, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: onValueChanged.m_PersistentCalls.m_Calls.Array.size
@ -1656,9 +1680,21 @@ PrefabInstance:
propertyPath: m_SizeDelta.x
value: 267.551
objectReference: {fileID: 0}
- target: {fileID: 3849503019427133880, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_SizeDelta.x
value: 160.437
objectReference: {fileID: 0}
- target: {fileID: 3849503019427133880, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_SizeDelta.y
value: 420.253
objectReference: {fileID: 0}
- target: {fileID: 3849503019427133880, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_AnchoredPosition.x
value: -8.4917
objectReference: {fileID: 0}
- target: {fileID: 3849503019427133883, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4599960695770769989, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_AnchorMax.x
@ -1670,7 +1706,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4599960695770769989, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: -2.275772
objectReference: {fileID: 0}
- target: {fileID: 5134555548762687368, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_AnchorMax.x
@ -1682,7 +1718,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5134555548762687368, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: -2.2757874
objectReference: {fileID: 0}
- target: {fileID: 7187413038405322106, guid: 26d5710936f5f7d468eb5eb9da96112e, type: 3}
propertyPath: panel
@ -2334,6 +2370,7 @@ MonoBehaviour:
toggleImage:
- {fileID: 21300000, guid: 9b39ad4a6d4365f4b937bebb942cd186, type: 3}
- {fileID: 21300000, guid: 33cc51e785571694a82fca6e26492330, type: 3}
titleText: {fileID: 1343620366}
ManagerPanel: {fileID: 617308871}
peopleCountent: {fileID: 667280287}
peoplePrefab: {fileID: 4204671800070690484, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3}
@ -7018,6 +7055,18 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 618256462}
m_TargetAssemblyTypeName: Panel, Assembly-CSharp
m_MethodName: SetTitleText
m_Mode: 2
m_Arguments:
m_ObjectArgument: {fileID: 1256342110}
m_ObjectArgumentAssemblyTypeName: UnityEngine.UI.Text, UnityEngine.UI
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_IsOn: 0
--- !u!114 &1194981514
MonoBehaviour:
@ -7344,6 +7393,18 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 618256462}
m_TargetAssemblyTypeName: Panel, Assembly-CSharp
m_MethodName: SetTitleText
m_Mode: 2
m_Arguments:
m_ObjectArgument: {fileID: 191833649}
m_ObjectArgumentAssemblyTypeName: UnityEngine.UI.Text, UnityEngine.UI
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_IsOn: 0
--- !u!114 &1247260777
MonoBehaviour:
@ -10036,6 +10097,18 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 618256462}
m_TargetAssemblyTypeName: Panel, Assembly-CSharp
m_MethodName: SetTitleText
m_Mode: 2
m_Arguments:
m_ObjectArgument: {fileID: 2011236325}
m_ObjectArgumentAssemblyTypeName: UnityEngine.UI.Text, UnityEngine.UI
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_IsOn: 0
--- !u!114 &1783365055
MonoBehaviour:
@ -14990,9 +15063,9 @@ RectTransform:
m_Father: {fileID: 7468736063934366934}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 334.1322, y: -55}
m_SizeDelta: {x: 187, y: 110}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7468736064122132329
@ -15273,9 +15346,9 @@ RectTransform:
m_Father: {fileID: 7468736063934366934}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 753.3966, y: -55}
m_SizeDelta: {x: 187, y: 110}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7468736064198941274
@ -16089,6 +16162,7 @@ MonoBehaviour:
incidentLable: {fileID: 7468736064937661071}
randomEventBtn: {fileID: 7468736064832119474}
text20008: {fileID: 7468736063763417177}
text20010: {fileID: 7468736065139644656}
title: {fileID: 7468736063763417177}
schoolInfoList:
- {fileID: 7468736064927213727}
@ -16515,9 +16589,9 @@ RectTransform:
m_Father: {fileID: 7468736063934366934}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 543.7644, y: -55}
m_SizeDelta: {x: 187, y: 110}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7468736064659112359
@ -16883,9 +16957,9 @@ RectTransform:
m_Father: {fileID: 7468736063934366934}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 124.5, y: -55}
m_SizeDelta: {x: 187, y: 110}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7468736064820222392
@ -17296,9 +17370,9 @@ RectTransform:
m_Father: {fileID: 7468736064579811971}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 917, y: -1328.051}
m_SizeDelta: {x: 1834, y: 498.685}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7468736064937661071
@ -17316,7 +17390,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!222 &7468736065013593257
CanvasRenderer:
m_ObjectHideFlags: 0
@ -18552,9 +18626,9 @@ RectTransform:
m_Father: {fileID: 7468736064579811971}
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: 917, y: -588.33496}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1834, y: 498.685}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7468736065836200803
@ -18572,7 +18646,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!114 &8920314133631286993
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -368,10 +368,10 @@ public class JSONReader : MonoBehaviour
}
//设置UI文本的方法
public string SetUIText(int id)
public string SetUIText(string id)
{
Language info = null;
if (LanguageDictionary.TryGetValue(id, out info))
if (LanguageDictionary.TryGetValue(int.Parse(id), out info))
{
return info.Text;
}

View File

@ -50,6 +50,8 @@ public class Panel : Base
[Header("面板选择")]
public Toggle[] panelToggle;//面板选择Toggle
public Sprite[] toggleImage;//面板选择图片
[Header("UI面板名")]
public Text titleText;
[Header("物体")]
@ -166,7 +168,7 @@ public class Panel : Base
GameObject item = GameObject.Instantiate(dutyPrefab, dutyCount);
DutyItem dutyItem = item.GetComponent<DutyItem>();
Button dutuybutton = item.transform.Find("TextBtn").GetComponent<Button>();
string showText = jsonReader1.SetUIText(int.Parse(peopleLimit[2]));
string showText = jsonReader1.SetUIText(peopleLimit[2]);
dutuybutton.onClick.AddListener(() =>
{
OnDutyItemClicked(item, Color.red, selectedDuty);
@ -212,7 +214,7 @@ public class Panel : Base
// 设置limitNum
sceneItem.sceneId = npcData.ToString();
LocationData locationData= jsonReader1.GetAreaDateById(int.Parse(npcData));
sceneItem.sceneName.text = jsonReader1.SetUIText(locationData.Name);
sceneItem.sceneName.text = jsonReader1.SetUIText(locationData.Name.ToString());
//Debug.LogError(sceneItem.sceneId);
// 将每个实例化的角色添加到列表中
peopleList.Add(item);
@ -555,7 +557,6 @@ public class Panel : Base
datePanel.NumberText.text = "共" + sceneDataDictionary.Sum(kvp => kvp.Value.Count).ToString() + "人参与";
}
//处理界面关闭按钮
public void ClickCloseBtn()
{
@ -650,6 +651,7 @@ public class Panel : Base
panelToggle[2].gameObject.transform.GetComponent<Image>().sprite = toggleImage[1];
}
}
//设置最初的时候Toggle的状态
public void InstantiateToggle()
{
@ -836,6 +838,18 @@ public class Panel : Base
sureBtn.transform.GetComponent<Image>().sprite = toggleImage[0];
}
}
//设置文本
public void SetTitleText(Text setText)
{
titleText.text = setText.text;
}
//场景选择设置失活
public void SetTransfrom()
{
transform.gameObject.SetActive(false);
}
}

View File

@ -132,7 +132,7 @@ public class DistributionPanel : MonoBehaviour
foreach (var missingDutyId in missingDutyIds)
{
// 获取职业名称(假设 SetUIText 方法用于获取职业名称)
missingCountMessage += jsonReader.SetUIText(int.Parse(missingDutyId)) + " ";
missingCountMessage += jsonReader.SetUIText(missingDutyId) + " ";
}
return missingCountMessage;
}

View File

@ -124,20 +124,13 @@ public class EvacuationPanel : MonoBehaviour
//文字框提交按钮
public void Submit()
{
// 输入验证
int count;
if (!int.TryParse(StuCountInputField.text, out count) || count <= 0)
{
Debug.LogError("请输入有效的总人数!");
return;
}
//StuCountInputField.text = "";
// 调用分配方法
var result = DistributeNpcByRatio(personnelItems, count);
// 更新 UI 和数据
foreach (var kvp in result)
{
PersonnelItem item = personnelItems.Find(p => p.sceneId == kvp.Key);
@ -232,7 +225,7 @@ public class EvacuationPanel : MonoBehaviour
GameObject sceneitem = GameObject.Instantiate(personnelPrefabs, personnelContent);
PersonnelItem personnelItem = sceneitem.GetComponent<PersonnelItem>();
Button button = personnelItem.transform.Find("sceneText").GetComponent<Button>();
personnelItem.sceneText.text = js.SetUIText(item.Value.Name);
personnelItem.sceneText.text = js.SetUIText(item.Value.Name.ToString());
personnelItem.sceneId = item.Key;
personnelItem.Num = 1; // 设置初始值为 1
// 点击事件监听
@ -475,18 +468,14 @@ public class EvacuationPanel : MonoBehaviour
if (levelLimit[0] != "0")
{
// 获取楼层名称
string className = js.SetUIText(int.Parse(levelLimit[1]));
string className = js.SetUIText(levelLimit[1]);
// 如果楼层名称已经加载过,则跳过
if (loadedClassNames.Contains(className))
{
continue; // 跳过该楼层
}
// 否则,添加到 HashSet
loadedClassNames.Add(className);
// 加载楼层
GameObject levelItem = GameObject.Instantiate(scenePrefab, sceneCount);
ClassItem classLevel = levelItem.GetComponent<ClassItem>();
classLevel.classname.text = className;
@ -496,6 +485,7 @@ public class EvacuationPanel : MonoBehaviour
{
JueseChoicePop jueseChoicePop = jueseChoicePanel.GetComponent<JueseChoicePop>();
jueseChoicePanel.gameObject.SetActive(true);
//jueseChoicePanel.SetClass();
});
ClassItem classItem = levelItem.GetComponent<ClassItem>();

View File

@ -29,6 +29,7 @@ public class SelectScenePanel : Base
public GameObject incidentLable;//事件场景界面
public Button randomEventBtn;//随机事件按钮
[Header("请选择演练的场景")] public Text text20008;
[Header("ÇëÑ¡ÔñÑÝÁ·ÄѶÈ")] public Text text20010;
public Text title;//界面标题
public List<SchoolInfo> schoolInfoList = new List<SchoolInfo>();//学校信息
public List<EventInfo> eventInfoList = new List<EventInfo>();//事件信息
@ -154,7 +155,7 @@ public class SelectScenePanel : Base
{
GameObject slot = GameObject.Instantiate<GameObject>(schoolPrefab, schoolList);
SchoolInfo item = slot.GetComponent<SchoolInfo>();
item.schoolName.text = sceneDate.Value.Name;
item.schoolName.text = jsonReader.SetUIText(sceneDate.Value.Name);
item.schoolId = sceneDate.Value.ID;
Toggle toggle = slot.GetComponent<Toggle>();
@ -267,10 +268,8 @@ public class SelectScenePanel : Base
{
Destroy(child.gameObject);
}
// 更新场景名称
text20008.text = schoolName;
// 通过 id 获取对应的 sceneData
if (jsonReader.sceneDictionary.TryGetValue(id, out var sceneData))
{
@ -470,6 +469,7 @@ public class SelectScenePanel : Base
schoolChoiceLable.gameObject.SetActive(true);
eventChoiceLable.gameObject.SetActive(false);
incidentLable.gameObject.SetActive(false);
text20008.text = jsonReader.SetUIText("20008");
}
else
{

View File

@ -793,8 +793,8 @@ public class ZZUIManager : MonoBehaviour
GameObject newItem = Instantiate(itemPrefab, content3.transform);
Text left = newItem.transform.Find("Choose_Bg/Choose_BgLeft/Left").GetComponent<Text>();
Text Right = newItem.transform.Find("Choose_Bg/Choose_BgLeft/Right").GetComponent<Text>();
left.text = jsonReader.SetUIText(20000);
Right.text = jsonReader.SetUIText(ID+i);
left.text = jsonReader.SetUIText("20000");
Right.text = jsonReader.SetUIText((ID+i).ToString());
Toggle toggle = newItem.gameObject.GetComponent<Toggle>();
Choose1 chooseScript = newItem.GetComponent<Choose1>();
toggle.group = toggleGroup;
@ -837,8 +837,8 @@ public class ZZUIManager : MonoBehaviour
GameObject newItem = Instantiate(itemPrefab, content3.transform);
Text left = newItem.transform.Find("Choose_Bg/Choose_BgLeft/Left").GetComponent<Text>();
Text Right = newItem.transform.Find("Choose_Bg/Choose_BgLeft/Right").GetComponent<Text>();
left.text = jsonReader.SetUIText(20000);
Right.text = jsonReader.SetUIText(ID);
left.text = jsonReader.SetUIText("20000");
Right.text = jsonReader.SetUIText(ID.ToString());
Toggle toggle = newItem.gameObject.GetComponent<Toggle>();
Choose1 chooseScript = newItem.GetComponent<Choose1>();
toggle.group = toggleGroup;

View File

@ -55,36 +55,26 @@ public class JueseChoicePop : MonoBehaviour
//加载分管人员
public void SetClass(int id, string scnenName)
{
Debug.LogError(">>>>>>>>>>>>>>>>>>>>>>>>>>"+id);
// 检查是否已经实例化过该 id 的对象
if (instantiatedObjects.Any(obj => obj.GetComponent<ClassMate>().id == id))
{
Debug.Log($"这个: {id} 已经被实例化.");
return; // 如果已实例化,跳过
}
// 清除当前内容
foreach (Transform child in content)
{
Destroy(child.gameObject);
}
// 获取指定 ID 的 LocationData
LocationData locationData = jsonReader.GetAreaDateById(id);
// 判断 Oversee 字段
if (locationData.Oversee == "-1")
{
Debug.Log($"Skipping ID {id}: Oversee is -1.");
return; // 跳过
}
// 分割 Oversee 字段
string[] overseeParts = locationData.Oversee.Split(',');
string firstElement = overseeParts[0];
string lastElement = overseeParts[1];
if (overseeParts.Length > 0)
{
// 判断第一个元素是否为 "1"
if (lastElement == "1")
{
foreach (var pair in panel.sceneDataDictionary)
@ -102,7 +92,6 @@ public class JueseChoicePop : MonoBehaviour
classMate.name = selectedInfo.name;
classMate.classmatename.text = classMate.name;
classMate.id = id;
// 将实例化的对象添加到列表中
instantiatedObjects.Add(item);
}
}
@ -111,8 +100,6 @@ public class JueseChoicePop : MonoBehaviour
}
}
}
//点击人员后设置位置的方法
public void SetClassMate(ClassMate classMate, string a = "")
{