_xiaofang/xiaofang/Assets/Script/UI/PanelUI/ManagerPanel.cs

116 lines
3.8 KiB
C#
Raw Normal View History

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;
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-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
}
//public void SetPlate()
//{
// // <20><><EFBFBD>յ<EFBFBD>ǰ<EFBFBD><C7B0>ʾ
// foreach (Transform child in managerPanelContent)
// {
// Debug.Log("Destroying: " + child.gameObject.name);
// Destroy(child.gameObject);
// }
2024-11-27 16:54:09 +08:00
// // <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>
// }
//}
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>
public void CreateScenePanel(string sceneName, List<SelectedInfo> peopleList,GameObject parentTransform)
2024-11-27 16:54:09 +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)
{
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>
private void CreatePersonItem(SelectedInfo person, GameObject parentTransform)
2024-11-27 16:54:09 +08:00
{
Transform contentTransform = parentTransform.transform.Find("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>
GameObject item = Instantiate(personItemPrefab, contentTransform);
ArrangementItem arrangementItem = item.GetComponent<ArrangementItem>();
2024-11-27 16:54:09 +08:00
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>
//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;
//}
}