使用Unity完成简单的背包功能
用UGUI布局成一下这个样子
设置BackGround的tag为Bag
Lft,Center,Right设置为Groove
所有的Item设置为BagItem
在BackGround中添加组件Grid Layout Group,使拖动上去之后能够正确排版
并且为所有item添加CanvasGroup组件,当BlockRaycasts为false时使射线能够穿透该物体,反则则不能
编写脚本
在BackGround上挂载的脚本.m_BagPageMgr,这是一个管理类
using UnityEngine;
public class m_BagPageMgr : MonoBehaviour
{
Transform _Panle; //保存Panle的Transform
Transform BackGound; //保存BackGround的Transform
void Awake()
{
_Panle = transform.parent.GetComponent(); //获取到Transform组件
BackGound = GetC