UI逻辑更改
This commit is contained in:
parent
9d79de6f6e
commit
2833129a25
Binary file not shown.
Before Width: | Height: | Size: 2.3 MiB |
@ -1,123 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 1cfc105de79baef44a26945245beddc3
|
|
||||||
TextureImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 12
|
|
||||||
mipmaps:
|
|
||||||
mipMapMode: 0
|
|
||||||
enableMipMap: 0
|
|
||||||
sRGBTexture: 1
|
|
||||||
linearTexture: 0
|
|
||||||
fadeOut: 0
|
|
||||||
borderMipMap: 0
|
|
||||||
mipMapsPreserveCoverage: 0
|
|
||||||
alphaTestReferenceValue: 0.5
|
|
||||||
mipMapFadeDistanceStart: 1
|
|
||||||
mipMapFadeDistanceEnd: 3
|
|
||||||
bumpmap:
|
|
||||||
convertToNormalMap: 0
|
|
||||||
externalNormalMap: 0
|
|
||||||
heightScale: 0.25
|
|
||||||
normalMapFilter: 0
|
|
||||||
isReadable: 0
|
|
||||||
streamingMipmaps: 0
|
|
||||||
streamingMipmapsPriority: 0
|
|
||||||
vTOnly: 0
|
|
||||||
ignoreMasterTextureLimit: 0
|
|
||||||
grayScaleToAlpha: 0
|
|
||||||
generateCubemap: 6
|
|
||||||
cubemapConvolution: 0
|
|
||||||
seamlessCubemap: 0
|
|
||||||
textureFormat: 1
|
|
||||||
maxTextureSize: 2048
|
|
||||||
textureSettings:
|
|
||||||
serializedVersion: 2
|
|
||||||
filterMode: 1
|
|
||||||
aniso: 1
|
|
||||||
mipBias: 0
|
|
||||||
wrapU: 1
|
|
||||||
wrapV: 1
|
|
||||||
wrapW: 0
|
|
||||||
nPOTScale: 0
|
|
||||||
lightmap: 0
|
|
||||||
compressionQuality: 50
|
|
||||||
spriteMode: 1
|
|
||||||
spriteExtrude: 1
|
|
||||||
spriteMeshType: 1
|
|
||||||
alignment: 0
|
|
||||||
spritePivot: {x: 0.5, y: 0.5}
|
|
||||||
spritePixelsToUnits: 100
|
|
||||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
spriteGenerateFallbackPhysicsShape: 1
|
|
||||||
alphaUsage: 1
|
|
||||||
alphaIsTransparency: 1
|
|
||||||
spriteTessellationDetail: -1
|
|
||||||
textureType: 8
|
|
||||||
textureShape: 1
|
|
||||||
singleChannelComponent: 0
|
|
||||||
flipbookRows: 1
|
|
||||||
flipbookColumns: 1
|
|
||||||
maxTextureSizeSet: 0
|
|
||||||
compressionQualitySet: 0
|
|
||||||
textureFormatSet: 0
|
|
||||||
ignorePngGamma: 0
|
|
||||||
applyGammaDecoding: 0
|
|
||||||
cookieLightType: 0
|
|
||||||
platformSettings:
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: DefaultTexturePlatform
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: Standalone
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: Android
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
spriteSheet:
|
|
||||||
serializedVersion: 2
|
|
||||||
sprites: []
|
|
||||||
outline: []
|
|
||||||
physicsShape: []
|
|
||||||
bones: []
|
|
||||||
spriteID: 5e97eb03825dee720800000000000000
|
|
||||||
internalID: 0
|
|
||||||
vertices: []
|
|
||||||
indices:
|
|
||||||
edges: []
|
|
||||||
weights: []
|
|
||||||
secondaryTextures: []
|
|
||||||
nameFileIdTable: {}
|
|
||||||
spritePackingTag:
|
|
||||||
pSDRemoveMatte: 0
|
|
||||||
pSDShowRemoveMatteOption: 0
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
File diff suppressed because it is too large
Load Diff
@ -44,7 +44,7 @@ public class Panel : MonoBehaviour
|
|||||||
private List<GameObject> filteredPeopleList = new List<GameObject>(); // 存储筛选后的人员列表
|
private List<GameObject> filteredPeopleList = new List<GameObject>(); // 存储筛选后的人员列表
|
||||||
private GameObject selectedPerson = null; // 当前选中的角色
|
private GameObject selectedPerson = null; // 当前选中的角色
|
||||||
public SelectedInfo selectedInfo;
|
public SelectedInfo selectedInfo;
|
||||||
private Dictionary<string, List<SelectedInfo>> sceneDataDictionary = new Dictionary<string, List<SelectedInfo>>();//不同的场景存取不同的人员数据
|
public Dictionary<string, List<SelectedInfo>> sceneDataDictionary = new Dictionary<string, List<SelectedInfo>>();//不同的场景存取不同的人员数据
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
@ -87,6 +87,10 @@ public class Panel : MonoBehaviour
|
|||||||
{
|
{
|
||||||
sceneDataDictionary[sceneName] = new List<SelectedInfo>();
|
sceneDataDictionary[sceneName] = new List<SelectedInfo>();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("没有选场景");
|
||||||
|
}
|
||||||
|
|
||||||
// 将当前选中的人员信息添加到对应场景的人员列表中
|
// 将当前选中的人员信息添加到对应场景的人员列表中
|
||||||
sceneDataDictionary[sceneName].Add(selectedInfo);
|
sceneDataDictionary[sceneName].Add(selectedInfo);
|
||||||
|
@ -6,21 +6,119 @@ using UnityEngine.UI;
|
|||||||
//板块信息
|
//板块信息
|
||||||
public class ManagerPanel : MonoBehaviour
|
public class ManagerPanel : MonoBehaviour
|
||||||
{
|
{
|
||||||
public List<PlateInfo> platesList = new List<PlateInfo>();
|
public Panel panelScript; // 引用Panel类的实例
|
||||||
|
public Transform managerPanelContent; // 管理面板中用于显示人员的UI容器
|
||||||
|
public Transform panelContent;
|
||||||
|
public GameObject personItemPrefab; // 用于显示人员信息的UI项
|
||||||
|
public GameObject scenePanelPrefab;
|
||||||
|
|
||||||
|
[Header("组件")]
|
||||||
|
public Text sceneText;
|
||||||
|
public Text nameText;
|
||||||
|
public Text dutyText;
|
||||||
|
|
||||||
|
[Header("数据")]
|
||||||
|
private GameObject currentSelectedItem = null; // 当前选中的项
|
||||||
|
private Vector3 originalScale; // 记录选中项的原始大小
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
//SetPlate();
|
||||||
}
|
}
|
||||||
//更新板块人员信息
|
public void SetPlate()
|
||||||
void SetPlate()
|
|
||||||
{
|
{
|
||||||
|
// 清空当前显示
|
||||||
|
foreach (Transform child in managerPanelContent)
|
||||||
|
{
|
||||||
|
Debug.Log("Destroying: " + child.gameObject.name);
|
||||||
|
Destroy(child.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 遍历字典中的每个场景,生成对应的UI项
|
||||||
|
foreach (var sceneEntry in panelScript.sceneDataDictionary)
|
||||||
|
{
|
||||||
|
CreateScenePanel(sceneEntry.Key, sceneEntry.Value); // 为每个场景调用封装的方法
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// 根据场景名称和对应的人员列表生成场景面板和人员项
|
||||||
|
private void CreateScenePanel(string sceneName, List<SelectedInfo> peopleList)
|
||||||
|
{
|
||||||
|
// 为每个场景生成一个新的面板
|
||||||
|
GameObject scenePanel = Instantiate(scenePanelPrefab, panelContent);
|
||||||
|
|
||||||
|
// 在每个场景面板上找到场景名称的文本组件并设置
|
||||||
|
Text sceneText = scenePanel.transform.Find("top/sceneName").GetComponent<Text>();
|
||||||
|
sceneText.text = sceneName;
|
||||||
|
|
||||||
|
// 遍历该场景下的所有人员,生成对应的UI项
|
||||||
|
foreach (SelectedInfo person in peopleList)
|
||||||
|
{
|
||||||
|
CreatePersonItem(scenePanel, person); // 调用封装方法生成人员项
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据人员信息生成一个UI项
|
||||||
|
private void CreatePersonItem(GameObject scenePanel, SelectedInfo person)
|
||||||
|
{
|
||||||
|
// 实例化一个人员项并将其作为场景面板的子物体
|
||||||
|
GameObject item = Instantiate(personItemPrefab, managerPanelContent);
|
||||||
|
|
||||||
|
// 获取并设置人员信息
|
||||||
|
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; // 设置姓名
|
||||||
|
dutyText.text = person.duty; // 设置职责
|
||||||
|
}
|
||||||
|
// 点击项时调用
|
||||||
|
//public void OnItemClicked(GameObject clickedItem)
|
||||||
|
//{
|
||||||
|
// // 如果有之前选中的项,恢复其原始大小
|
||||||
|
// if (currentSelectedItem != null)
|
||||||
|
// {
|
||||||
|
// RectTransform rt = currentSelectedItem.GetComponent<RectTransform>();
|
||||||
|
// rt.localScale = originalScale; // 恢复原始大小
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 更新当前选中的项
|
||||||
|
// currentSelectedItem = clickedItem;
|
||||||
|
// RectTransform clickedItemRT = clickedItem.GetComponent<RectTransform>();
|
||||||
|
|
||||||
|
// // 放大当前选中的项
|
||||||
|
// clickedItemRT.localScale = originalScale * 1.5f; // 放大1.5倍
|
||||||
|
|
||||||
|
// // 使当前选中的项居中显示
|
||||||
|
// 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)); // 平滑滚动到目标位置
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// 平滑滚动到目标位置
|
||||||
|
//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;
|
||||||
|
//}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user