当前位置: 首页 > news >正文

上海医疗网站备案网业车资格证怎么报名

上海医疗网站备案,网业车资格证怎么报名,网站建设 html5,盲盒小程序加盟Unity2D初级背包设计中篇 MVC分层撰写(万字详解)-CSDN博客、 如果你已经搞懂了中篇#xff0c;那么对这个背包的拓展将极为简单#xff0c;我就在这里举个例子吧 目录 1.添加物品描述信息 2.拓展思路与不足分析 1.没有删除只有丢弃功能#xff0c;所以可以添加垃圾桶 2.格… Unity2D初级背包设计中篇 MVC分层撰写(万字详解)-CSDN博客、 如果你已经搞懂了中篇那么对这个背包的拓展将极为简单我就在这里举个例子吧 目录 1.添加物品描述信息 2.拓展思路与不足分析 1.没有删除只有丢弃功能所以可以添加垃圾桶 2.格子有限可以再做的大一些也可以添加翻页功能 3.排序与分类功能 4. 逻辑层再封装 5.背包存储可以转为json而不再是让编辑器保存 1.添加物品描述信息 M层修改 统一到SoltData之中获得  using System; using System.Collections; using System.Collections.Generic; using UnityEngine;[Serializable] public class SlotData {public ItemData item;public int currentCount 0; // 物品数量private Action OnChange;#region 增Add// 添加物品到槽位public void Add(int numToAdd 1) {this.currentCount numToAdd;OnChange?.Invoke();}// 设置槽位的物品和数量public void AddItem(ItemData item, int count 1) {this.item item;this.currentCount count;OnChange?.Invoke();}#endregion#region 删Remove// 减少槽位中的物品数量public void Reduce(int numToReduce 1) {currentCount - numToReduce;if (currentCount 0) {Clear();}else {OnChange?.Invoke();}}// 清空槽位public void Clear() {item null;currentCount 0;OnChange?.Invoke();}#endregion#region 查Check// 检查槽位是否为空public bool IsEmpty() {return currentCount 0;}// 检查槽位是否可以添加物品public bool CanAddItem() {return currentCount item.maxCount;}// 获取槽位的空余空间public int GetFreeSpace() {return item.maxCount - currentCount;}#endregion#region 改Update// 移动槽位数据public void MoveSlot(SlotData data) {this.item data.item;this.currentCount data.currentCount;OnChange?.Invoke();}// 添加监听器public void AddListener(Action OnChange) {this.OnChange OnChange;}//获取物品描述public string GetDescription() {return item.Description;}#endregion }V层修改 背包UI持有该描述的组件 因此将显示和隐藏写到BagUI类  using System.Collections.Generic; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI;public class BagUI : MonoBehaviour {[SerializeField] private Button close;[SerializeField] private GameObject BG;[SerializeField] private GameObject slotGrid;[SerializeField] private ListSlotUI soltuiList new ListSlotUI();[SerializeField] private TextMeshProUGUI DText;// Start is called once before the first execution of Update after the MonoBehaviour is createdvoid Start() {InitElement();InitSlotUI();}// Update is called once per framevoid Update() {ColseBag();}public void InitElement() {if(BGnull)BG transform.Find(BG).gameObject;if (close null)close transform.Find(BG/BgElement/Close).GetComponentButton();if(slotGrid)slotGrid transform.Find(BG/SlotGrid).gameObject;if (close ! null) {close.onClick.AddListener(() {if (BG ! null)BG.SetActive(!BG.activeSelf);else {Debug.LogWarning(没找到BG对象);return;}});}elseDebug.LogWarning(没有加载到close按钮);}public void UpdataUI() {for (int i 0; i InventoryManager.Instance.BagInventory.slotList.Count; i) {soltuiList[i].SetData(InventoryManager.Instance.BagInventory.slotList[i]);}}public void InitSlotUI() {if (slotGrid ! null) {foreach (SlotUI slotUi in slotGrid.GetComponentsInChildrenSlotUI()) {soltuiList.Add(slotUi);}}UpdataUI();}public void ColseBag() {if (Input.GetKeyDown(KeyCode.Tab))BG.SetActive(!BG.activeSelf);}public void ShowDescription(string description) {DText.gameObject.SetActive(true);DText.text description;}public void HideDescription() {DText.gameObject.SetActive(false);DText.text ;}}之后当鼠标移入SoltUI之后触发上面两种方法 ,这里可以采用事件发送的方法也可以直接去持有对象 using System; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; using UnityEngine.UI;public class SlotUI : MonoBehaviour,IPointerClickHandler,IPointerEnterHandler, IPointerExitHandler {protected SlotData slotData;protected Image icon;protected TextMeshProUGUI num;[SerializeField]private BagUI bagUI;private void Start() {icon transform.Find(icon).GetComponentImage();num transform.Find(num).GetComponentTextMeshProUGUI();}public SlotData GetData(){ return slotData;}/// summary/// 为该脚本上的对象赋值一个SlotData/// /summarypublic void SetData(SlotData slotData) { this.slotData slotData;//事件监听 - 订阅者slotData.AddListener(UpdateUI2Slot);UpdateUI2Slot();}/ summary/ 监听对象/ /summary//public void ChangeUI(){// UpdateUI2Slot();//}private void UpdateUI2Slot(){if (slotDatanull || slotData.item null || slotData.currentCount 0) {icon.enabled false;num.enabled false;}else {icon.enabled true;num.enabled true;icon.sprite slotData.item.itemSprite;num.text slotData.currentCount.ToString();}}public void OnPointerClick(PointerEventData eventData) {Debug.Log(发生了点击);ItemMoveHandler.Instance.OnSlotClick(this);}public void OnPointerEnter(PointerEventData eventData) {Debug.Log(鼠标进入);if (slotData.item ! null)bagUI.ShowDescription(slotData.GetDescription());}public void OnPointerExit(PointerEventData eventData) {Debug.Log(鼠标离开);if (slotData.item ! null)bagUI.HideDescription();} } 2.拓展思路与不足分析 1.没有删除只有丢弃功能所以可以添加垃圾桶 2.格子有限可以再做的大一些也可以添加翻页功能 3.排序与分类功能 这个我将会在通用背包文章之中进行详细解释 4. 逻辑层再封装 因为物品小类自有的枚举工具/消耗品/可捡起的枚举在配置上比较烦 应该做到实时判断也就是策划只需要给物品配置 然后一键导入就行了 只需要 不再需要 5.背包存储可以转为json而不再是让编辑器保存 以上2D初级背包结束
http://www.hkea.cn/news/14555510/

相关文章:

  • asp网站建设教程四站合一网站建设
  • 阿里网站多个域名凡科平台盲审
  • dedecms本地调试好的网站怎么上传到服务器完整网站开发教程
  • 网站关键词被百度屏蔽怎么办搜索不到我的网站
  • 天津做网站报价国内十大搜索引擎
  • 梅州市住房和建设局网站深圳企业网站建设企业
  • 外贸网站google推广室内设计方案网站
  • 自己建设网站不会咋办呀住房和城乡建设部科技网站首页
  • 新网互联 网站上传常州网站建设企业网站制作
  • 郑州网站建设zzmshlwordpress 删除版权信息
  • 企业网站报价网站建设服务好公司排名
  • 新校区建设网站管理规定pc网站向手机站传递权重
  • 网页建设网站代码wordpress 图片加速
  • wordpress自动标签内联太原百度seo优化推广
  • 校园文化建设网站素材小荷特卖的网站谁做的
  • 企业建设网站的过程网站建设明细报价单
  • 网站首页全屏怎么做做移动网站
  • 肇庆企业做网站柳江企业网站建设公司
  • 做网站必须用域名吗做数学网站
  • 青州网站建设公司包装盒网站模板下载
  • wordpress 仿站 菜单wordpress移动支付免费
  • 上海全国网站建设wordpress主题怎么该轮播
  • 东莞技术好的网站建设推广个人网站建设的论文
  • 做venn图的网站wordpress商店会员管理
  • 行业门户网站开发广告设计公司服务方案
  • wordpress 数据库丢失seo网站推广有哪些
  • 深圳中心网站建设wordpress 好 免费主题
  • 信阳网站开发建设公司网站建设电话销售话术技巧
  • html怎么做网站设计定制型网站建设合同范本
  • 织梦网站模板免费下载wordpress该域名