From 55d17b0835af69652fcd48477a90252b60cde5d3 Mon Sep 17 00:00:00 2001 From: lq <3298408835@qq.com> Date: Fri, 29 Nov 2024 09:44:45 +0800 Subject: [PATCH] =?UTF-8?q?UI=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Script/UI/ArrangementItem.cs | 23 ++++++++ xiaofang/Assets/Script/UI/DateItem.cs | 27 +++++++++ xiaofang/Assets/Script/UI/MaterialItem.cs | 62 ++++++++++++++++++++ xiaofang/Assets/Script/UI/PeopleItem.cs | 50 ++++++++++++++++ xiaofang/Assets/Script/UI/PersonnelItem.cs | 24 ++++++++ xiaofang/Assets/Script/UI/SceneItem.cs | 23 ++++++++ xiaofang/Assets/Script/UI/Tools.cs | 26 ++++++++ 7 files changed, 235 insertions(+) create mode 100644 xiaofang/Assets/Script/UI/ArrangementItem.cs create mode 100644 xiaofang/Assets/Script/UI/DateItem.cs create mode 100644 xiaofang/Assets/Script/UI/MaterialItem.cs create mode 100644 xiaofang/Assets/Script/UI/PeopleItem.cs create mode 100644 xiaofang/Assets/Script/UI/PersonnelItem.cs create mode 100644 xiaofang/Assets/Script/UI/SceneItem.cs create mode 100644 xiaofang/Assets/Script/UI/Tools.cs diff --git a/xiaofang/Assets/Script/UI/ArrangementItem.cs b/xiaofang/Assets/Script/UI/ArrangementItem.cs new file mode 100644 index 00000000..47701282 --- /dev/null +++ b/xiaofang/Assets/Script/UI/ArrangementItem.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class ArrangementItem : MonoBehaviour +{ + public Image image; + public Text name; + public Text duty; + + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/xiaofang/Assets/Script/UI/DateItem.cs b/xiaofang/Assets/Script/UI/DateItem.cs new file mode 100644 index 00000000..40a6ed9c --- /dev/null +++ b/xiaofang/Assets/Script/UI/DateItem.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class DateItem : MonoBehaviour +{ + public Text dateText; + CalendarPanel calendarPanel; + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } + public void OnDaySelected(int day) + { + DateTime selectedDate = new DateTime(calendarPanel.currentDate.Year, calendarPanel.currentDate.Month, day); + calendarPanel.selectedDateText.text = "选择的日期: " + selectedDate.ToString("yyyy年MM月dd日"); + } +} diff --git a/xiaofang/Assets/Script/UI/MaterialItem.cs b/xiaofang/Assets/Script/UI/MaterialItem.cs new file mode 100644 index 00000000..d3d964a6 --- /dev/null +++ b/xiaofang/Assets/Script/UI/MaterialItem.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class MaterialItem : MonoBehaviour +{ + [Header("组件")] + public Text materialText; // 显示物资数量的文本 + public Image materialImage; // 物资图标 + public Text materialNameText; // 物资名称文本 + public Image hightImage; // 高亮图像 + + [Header("数据")] + public int materialNum = 0; // 物资数量 + public string materialName; // 物资名称 + + // Start is called before the first frame update + void Start() + { + materialText.text = materialNum.ToString(); // 初始化数量显示 + UpdateHighlightImage(); // 初始化高亮图像 + } + + // 增加物资数量 + public void AddNum() + { + materialNum++; + materialText.text = materialNum.ToString(); + UpdateHighlightImage(); // 更新高亮图像 + } + + // 减少物资数量 + public void SubtractNum() + { + if (materialNum > 0) + { + materialNum--; + materialText.text = materialNum.ToString(); + UpdateHighlightImage(); // 更新高亮图像 + } + } + + // 更新高亮图像的显示状态 + private void UpdateHighlightImage() + { + if (materialNum > 0) + { + hightImage.gameObject.SetActive(true); // 显示高亮图像 + } + else + { + hightImage.gameObject.SetActive(false); // 隐藏高亮图像 + } + } + + // 获取物资数量 + public int GetMaterialNum() + { + return materialNum; + } +} diff --git a/xiaofang/Assets/Script/UI/PeopleItem.cs b/xiaofang/Assets/Script/UI/PeopleItem.cs new file mode 100644 index 00000000..6fea117a --- /dev/null +++ b/xiaofang/Assets/Script/UI/PeopleItem.cs @@ -0,0 +1,50 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class PeopleItem : MonoBehaviour +{ + public Text nameText; // 人员名字显示 + public Button button; // 按钮,用来选择人员 + public Color defaultColor = Color.white; // 默认颜色 + public Color addedColor = Color.gray; // 已添加颜色 + public Color selectedColor = Color.yellow; // 选中颜色 + + public string Name { get; private set; } // 角色名字 + private bool isAdded; // 是否已添加 + private bool isSelected; // 是否选中 + + public delegate void ClickHandler(); + public event ClickHandler onClick; // 点击事件 + + // 设置人员项 + public void Setup(string name, bool added) + { + Name = name; + nameText.text = name; + SetAdded(added); + button.onClick.AddListener(OnButtonClick); + } + + // 设置已添加状态 + public void SetAdded(bool added) + { + isAdded = added; + nameText.color = isAdded ? addedColor : defaultColor; + } + + // 设置选中状态 + public void SetSelected(bool selected) + { + isSelected = selected; + nameText.fontSize = isSelected ? 24 : 14; // 选中后字体增大 + nameText.color = isSelected ? selectedColor : (isAdded ? addedColor : defaultColor); + } + + // 按钮点击事件 + private void OnButtonClick() + { + onClick?.Invoke(); + } +} diff --git a/xiaofang/Assets/Script/UI/PersonnelItem.cs b/xiaofang/Assets/Script/UI/PersonnelItem.cs new file mode 100644 index 00000000..7f231304 --- /dev/null +++ b/xiaofang/Assets/Script/UI/PersonnelItem.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class PersonnelItem : MonoBehaviour +{ + public Text sceneText; + public Image personnelImage; + public Text personnelNum; + + + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/xiaofang/Assets/Script/UI/SceneItem.cs b/xiaofang/Assets/Script/UI/SceneItem.cs new file mode 100644 index 00000000..8acc2a85 --- /dev/null +++ b/xiaofang/Assets/Script/UI/SceneItem.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class SceneItem : MonoBehaviour +{ + public Text sceneName; + public Image sceneImage; + public Image maskImage; + public bool IsOpen { get; set; } = true; + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/xiaofang/Assets/Script/UI/Tools.cs b/xiaofang/Assets/Script/UI/Tools.cs new file mode 100644 index 00000000..a60f9e26 --- /dev/null +++ b/xiaofang/Assets/Script/UI/Tools.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Tools : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } + //实例化预制体 + public void InstantiatePrefab(GameObject prefab, Transform content, int Num) + { + for (int i = 0; i < Num; i++) + { + GameObject item = GameObject.Instantiate(prefab, content); + } + } +}