2024-11-26 15:36:02 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
public class ManagerPanel : MonoBehaviour
|
|
|
|
|
{
|
2024-11-27 16:54:09 +08:00
|
|
|
|
public Panel panelScript; // <20><><EFBFBD><EFBFBD>Panel<65><6C><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
|
|
|
|
|
public Transform managerPanelContent; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ա<EFBFBD><D4B1>UI<55><49><EFBFBD><EFBFBD>
|
|
|
|
|
public Transform panelContent;
|
2024-11-29 20:05:19 +08:00
|
|
|
|
public Transform personnelPanelCount;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-11-27 16:54:09 +08:00
|
|
|
|
public GameObject personItemPrefab; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ա<EFBFBD><D4B1>Ϣ<EFBFBD><CFA2>UI<55><49>
|
|
|
|
|
public GameObject scenePanelPrefab;
|
2024-11-29 16:19:12 +08:00
|
|
|
|
public GameObject peopleWindowsPrefab;//<2F><>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
|
2024-11-29 20:05:19 +08:00
|
|
|
|
public GameObject personnelPanel;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
2024-12-02 00:35:53 +08:00
|
|
|
|
public JSONReader jsonReader;
|
2024-11-29 16:19:12 +08:00
|
|
|
|
|
2024-11-27 16:54:09 +08:00
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD>")]
|
|
|
|
|
public Text sceneText;
|
2024-11-29 16:19:12 +08:00
|
|
|
|
public ScrollRect scrollRect; // <20><><EFBFBD><EFBFBD>ScrollRect<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-11-27 16:54:09 +08:00
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD>")]
|
|
|
|
|
private GameObject currentSelectedItem = null; // <20><>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD>
|
|
|
|
|
private Vector3 originalScale; // <20><>¼ѡ<C2BC><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC>С
|
2024-11-29 20:05:19 +08:00
|
|
|
|
public Panel panelInfo;
|
2024-11-30 10:19:52 +08:00
|
|
|
|
public PersonnelPanel personnelPanel2;
|
|
|
|
|
|
2024-11-26 15:36:02 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2024-11-27 16:54:09 +08:00
|
|
|
|
|
2024-11-26 15:36:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
2024-11-28 11:56:28 +08:00
|
|
|
|
|
2024-11-26 15:36:02 +08:00
|
|
|
|
}
|
2024-11-27 16:54:09 +08:00
|
|
|
|
// <20><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƺͶ<C6BA>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ա<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>ɳ<EFBFBD><C9B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>
|
2024-11-28 01:31:46 +08:00
|
|
|
|
public void CreateScenePanel(string sceneName, List<SelectedInfo> peopleList,GameObject parentTransform)
|
2024-11-27 16:54:09 +08:00
|
|
|
|
{
|
2024-11-28 01:31:46 +08:00
|
|
|
|
if (personItemPrefab == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("personItemPrefab û<>б<EFBFBD><D0B1><EFBFBD>ȷ<EFBFBD><C8B7>ֵ<EFBFBD><D6B5>");
|
|
|
|
|
}
|
2024-11-27 16:54:09 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD>Ӧ<EFBFBD><D3A6>UI<55><49>
|
|
|
|
|
foreach (SelectedInfo person in peopleList)
|
|
|
|
|
{
|
2024-11-28 01:31:46 +08:00
|
|
|
|
CreatePersonItem(person, parentTransform); // <20><><EFBFBD><EFBFBD> managerPanelContent
|
2024-11-27 16:54:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>UI<55><49>
|
2024-11-28 01:31:46 +08:00
|
|
|
|
private void CreatePersonItem(SelectedInfo person, GameObject parentTransform)
|
2024-11-27 16:54:09 +08:00
|
|
|
|
{
|
2024-11-28 11:56:28 +08:00
|
|
|
|
Transform contentTransform = parentTransform.transform.Find("Scroll View/Viewport/Content");
|
2024-11-27 16:54:09 +08:00
|
|
|
|
// ʵ<><CAB5><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EEB2A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-11-28 01:31:46 +08:00
|
|
|
|
GameObject item = Instantiate(personItemPrefab, contentTransform);
|
|
|
|
|
ArrangementItem arrangementItem = item.GetComponent<ArrangementItem>();
|
|
|
|
|
arrangementItem.name.text = person.name; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
arrangementItem.duty.text = person.duty; // <20><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0>
|
2024-11-26 15:36:02 +08:00
|
|
|
|
}
|
2024-11-27 16:54:09 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
2024-11-28 11:56:28 +08:00
|
|
|
|
public void OnItemClicked(GameObject clickedItem)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ԭʼ<D4AD><CABC>С
|
|
|
|
|
if (currentSelectedItem != null)
|
|
|
|
|
{
|
|
|
|
|
RectTransform rt = currentSelectedItem.GetComponent<RectTransform>();
|
|
|
|
|
rt.localScale = originalScale; // <20>ָ<EFBFBD>ԭʼ<D4AD><CABC>С
|
|
|
|
|
}
|
|
|
|
|
// <20><>¼<EFBFBD><C2BC>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC>С
|
|
|
|
|
RectTransform clickedItemRT = clickedItem.GetComponent<RectTransform>();
|
|
|
|
|
if (originalScale == Vector3.zero)
|
|
|
|
|
{
|
|
|
|
|
originalScale = clickedItemRT.localScale; // ֻ<><D6BB>¼һ<C2BC><D2BB>ԭʼ<D4AD><CABC>С
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD>µ<EFBFBD>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD>
|
|
|
|
|
currentSelectedItem = clickedItem;
|
|
|
|
|
// <20>Ŵ<EFBFBD><C5B4><EFBFBD>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD>
|
|
|
|
|
clickedItemRT.localScale = originalScale * 1.2f; // <20>Ŵ<EFBFBD>1.2<EFBFBD><EFBFBD>
|
|
|
|
|
// ʹ<><CAB9>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
//CenterOnItem(clickedItemRT);
|
|
|
|
|
}
|
2024-12-04 16:37:51 +08:00
|
|
|
|
|
2024-11-28 11:56:28 +08:00
|
|
|
|
// ʹѡ<CAB9>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
private void CenterOnItem(RectTransform item)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ȡScrollView<65><77>Viewportλ<74><CEBB>
|
|
|
|
|
RectTransform viewportRect = scrollRect.viewport.GetComponent<RectTransform>();
|
2024-11-27 16:54:09 +08:00
|
|
|
|
|
2024-11-28 11:56:28 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿڵ<D3BF>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
|
|
|
|
|
float itemMinX = item.localPosition.x - item.rect.width / 2;
|
|
|
|
|
float itemMaxX = item.localPosition.x + item.rect.width / 2;
|
2024-11-27 16:54:09 +08:00
|
|
|
|
|
2024-11-28 11:56:28 +08:00
|
|
|
|
// <20><>ȡScroll Rect<63>Ŀ<EFBFBD><C4BF><EFBFBD>
|
|
|
|
|
float viewportWidth = viewportRect.rect.width;
|
2024-11-27 16:54:09 +08:00
|
|
|
|
|
2024-11-28 11:56:28 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>Normalized Position
|
|
|
|
|
float normalizedPos = Mathf.InverseLerp(itemMinX, itemMaxX, 0);
|
2024-11-27 16:54:09 +08:00
|
|
|
|
|
2024-11-28 11:56:28 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>Scroll Rect<63><74>normalizedPosition<6F><6E><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
|
|
|
|
|
scrollRect.horizontalNormalizedPosition = normalizedPos;
|
|
|
|
|
}
|
2024-11-29 16:19:12 +08:00
|
|
|
|
|
|
|
|
|
//<2F>رս<D8B1><D5BD><EFBFBD>
|
2024-11-28 11:56:28 +08:00
|
|
|
|
public void OnClickCloseBtn()
|
|
|
|
|
{
|
|
|
|
|
transform.gameObject.SetActive(false);
|
|
|
|
|
}
|
2024-11-29 16:19:12 +08:00
|
|
|
|
|
2024-11-30 10:19:52 +08:00
|
|
|
|
//<2F><>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
|
2024-11-29 16:19:12 +08:00
|
|
|
|
public void OnClickPeopleWindows()
|
|
|
|
|
{
|
|
|
|
|
peopleWindowsPrefab.gameObject.SetActive(true);
|
2024-11-29 20:05:19 +08:00
|
|
|
|
foreach (Transform child in personnelPanelCount)
|
|
|
|
|
{
|
|
|
|
|
Destroy(child.gameObject);
|
|
|
|
|
}
|
2024-12-18 21:31:25 +08:00
|
|
|
|
CreateFirstLable();
|
2024-11-29 20:05:19 +08:00
|
|
|
|
foreach (var sceneEntry in panelInfo.sceneDataDictionary)
|
|
|
|
|
{
|
|
|
|
|
GameObject managerPanelInstance = Instantiate(personnelPanel, personnelPanelCount);
|
2024-11-30 10:19:52 +08:00
|
|
|
|
PersonnelPanel scenetext = managerPanelInstance.GetComponent<PersonnelPanel>();
|
2024-12-18 21:31:25 +08:00
|
|
|
|
//foreach(var item in panelInfo.peopleList)
|
2024-11-30 10:19:52 +08:00
|
|
|
|
scenetext.personelPanelText.text = sceneEntry.Key;
|
|
|
|
|
scenetext.personelNumText.text = sceneEntry.Value.Count.ToString();
|
2024-12-10 08:05:28 +08:00
|
|
|
|
scenetext.CreatePeopleItem(sceneEntry.Value);
|
2024-11-29 20:05:19 +08:00
|
|
|
|
}
|
2024-12-04 16:37:51 +08:00
|
|
|
|
//CreatePeopleItem();
|
2024-11-29 16:19:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-30 23:32:17 +08:00
|
|
|
|
//<2F>ر<EFBFBD><D8B1><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
|
|
|
|
|
public void OnCloseWindowsBtn()
|
|
|
|
|
{
|
|
|
|
|
peopleWindowsPrefab.gameObject.SetActive(false);
|
|
|
|
|
}
|
2024-12-18 21:31:25 +08:00
|
|
|
|
public void CreateFirstLable()
|
|
|
|
|
{
|
|
|
|
|
GameObject fistLable = Instantiate<GameObject>(personnelPanel, personnelPanelCount);
|
|
|
|
|
PersonnelInfo personnelItem = fistLable.GetComponent<PersonnelInfo>();
|
|
|
|
|
}
|
2024-11-27 16:54:09 +08:00
|
|
|
|
}
|