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;
|
|
|
|
|
public GameObject personItemPrefab; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ա<EFBFBD><D4B1>Ϣ<EFBFBD><CFA2>UI<55><49>
|
|
|
|
|
public GameObject scenePanelPrefab;
|
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD>")]
|
|
|
|
|
public Text sceneText;
|
|
|
|
|
public Text nameText;
|
|
|
|
|
public Text dutyText;
|
|
|
|
|
|
|
|
|
|
[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-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-27 16:54:09 +08:00
|
|
|
|
//SetPlate();
|
2024-11-26 15:36:02 +08:00
|
|
|
|
}
|
2024-11-27 16:54:09 +08:00
|
|
|
|
public void SetPlate()
|
2024-11-26 15:36:02 +08:00
|
|
|
|
{
|
2024-11-27 16:54:09 +08:00
|
|
|
|
// <20><><EFBFBD>յ<EFBFBD>ǰ<EFBFBD><C7B0>ʾ
|
|
|
|
|
foreach (Transform child in managerPanelContent)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("Destroying: " + child.gameObject.name);
|
|
|
|
|
Destroy(child.gameObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>е<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD>Ӧ<EFBFBD><D3A6>UI<55><49>
|
|
|
|
|
foreach (var sceneEntry in panelScript.sceneDataDictionary)
|
|
|
|
|
{
|
|
|
|
|
CreateScenePanel(sceneEntry.Key, sceneEntry.Value); // Ϊÿ<CEAA><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD>װ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <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>
|
|
|
|
|
private void CreateScenePanel(string sceneName, List<SelectedInfo> peopleList)
|
|
|
|
|
{
|
|
|
|
|
// Ϊÿ<CEAA><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GameObject scenePanel = Instantiate(scenePanelPrefab, panelContent);
|
|
|
|
|
|
|
|
|
|
// <20><>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Text sceneText = scenePanel.transform.Find("top/sceneName").GetComponent<Text>();
|
|
|
|
|
sceneText.text = sceneName;
|
|
|
|
|
|
|
|
|
|
// <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)
|
|
|
|
|
{
|
|
|
|
|
CreatePersonItem(scenePanel, person); // <20><><EFBFBD>÷<EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>UI<55><49>
|
|
|
|
|
private void CreatePersonItem(GameObject scenePanel, SelectedInfo person)
|
|
|
|
|
{
|
|
|
|
|
// ʵ<><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>
|
|
|
|
|
GameObject item = Instantiate(personItemPrefab, managerPanelContent);
|
2024-11-26 15:36:02 +08:00
|
|
|
|
|
2024-11-27 16:54:09 +08:00
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>Ϣ
|
|
|
|
|
Text nameText = item.transform.Find("name").GetComponent<Text>();
|
|
|
|
|
Text dutyText = item.transform.Find("Profession").GetComponent<Text>();
|
|
|
|
|
|
|
|
|
|
Debug.Log("----------------------" + nameText.text);
|
|
|
|
|
Debug.Log("++++++++++++++++++++++" + dutyText.text);
|
|
|
|
|
nameText.text = person.name; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
dutyText.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>
|
|
|
|
|
//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>µ<EFBFBD>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD>
|
|
|
|
|
// currentSelectedItem = clickedItem;
|
|
|
|
|
// RectTransform clickedItemRT = clickedItem.GetComponent<RectTransform>();
|
|
|
|
|
|
|
|
|
|
// // <20>Ŵ<EFBFBD><C5B4><EFBFBD>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD>
|
|
|
|
|
// clickedItemRT.localScale = originalScale * 1.5f; // <20>Ŵ<EFBFBD>1.5<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
// // ʹ<><CAB9>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
// ScrollRect scrollRect = panelContent.GetComponentInParent<ScrollRect>();
|
|
|
|
|
// if (scrollRect != null)
|
|
|
|
|
// {
|
|
|
|
|
// float targetX = clickedItemRT.position.x - scrollRect.viewport.position.x;
|
|
|
|
|
// Vector3 targetPos = new Vector3(targetX, clickedItemRT.position.y, clickedItemRT.position.z);
|
|
|
|
|
// StartCoroutine(SmoothScrollToPosition(targetPos, 0.5f)); // ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//// ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>
|
|
|
|
|
//private IEnumerator SmoothScrollToPosition(Vector3 targetPosition, float duration)
|
|
|
|
|
//{
|
|
|
|
|
// Vector3 startPos = panelContent.position;
|
|
|
|
|
// float time = 0;
|
|
|
|
|
|
|
|
|
|
// while (time < duration)
|
|
|
|
|
// {
|
|
|
|
|
// panelContent.position = Vector3.Lerp(startPos, targetPosition, time / duration);
|
|
|
|
|
// time += Time.deltaTime;
|
|
|
|
|
// yield return null;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// panelContent.position = targetPosition;
|
|
|
|
|
//}
|
|
|
|
|
}
|