背包物品拖拽
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// 背包控制器
/// </summary>
public class PackageControl : MonoBehaviour{
public UIAtlas myAtlas;//图集
private string[] equipNames;//临时数据,和服务端交互时换成缓存数据
//组件
private GameObject preButton;
private GameObject nextButton;
private UILabel pageLabel;
private Transform packageStorage;
private Dictionary<int, GameObject> items = new Dictionary<int,
GameObject>();//保存背包格子
private Dictionary<GameObject, UISlicedSprite> icons = new
Dictionary<GameObject, UISlicedSprite>();//保存背包 Icon
private string draggedName;//当前拖拽物品名称
//分页
private int startItem = 0;//起始显示项
private int currentPage = 1;//当前页
private int totalPage;//总页数
private int pageSize;//每页大小
void Awake()
{
Transform paging = transform.FindChild("Paging");
preButton = paging.FindChild("PrePage").gameObject;
nextButton = paging.FindChild("NextPage").gameObject;
pageLabel =
paging.FindChild("Num").transform.GetComponent<UILabel>();
packageStorage = transform.FindChild("PackageStorage");
}
void Start ()
{
//临时数据
equipNames = new string[3];
equipNames[0] = "100001";equipNames[1] = "100002";equipNames[2]
评论30