NGUI之背包系统

背包系统的组件有:UIGrid,UIScrollview(循环)
NGUI原生的的UIsrollview 是没循环功能的,因此要想背包系统运行流畅,就必须将所有物品放在循环的scrollview中
不废话,直接上代码和效果图

效果图:

代码:

1 循环scrollview ( BackpackLoopScrollView )

using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using cl_ls;
using cl_gs;
using cl_gs_ex;
using cl_gs_checkpoint;
using System.Collections.Generic;
using System;
using evt;
using fil;
using tools;
using System.IO;
using enumtype;
[RequireComponent(typeof(UIGrid))]
public class BackpackLoopScrollView : MonoBehaviour
{
	#region Members
	private List<List<ITEM>>  _dataList; 
	private List<UIWidget>    _itemsList = new List<UIWidget>(); // 存储物件列表
	private Vector4           _posParam;
	private Transform         _cachedTransform; 
	private int               _startIndex;       // 起始下标  
	private int               _maxCount;         // 最大长度               
	public  UIScrollView      _scrollView;       // 父ScrollView 
	private UIGrid            _grid;
	private bool              _canSlideToleft=false;   //是否可以向左互动
	private bool              _canSlideToRight=false;  //是否可以向右滑动
	#endregion
	void Awake()
	{
		_cachedTransform = this.transform;
		_scrollView = _cachedTransform.parent.GetComponent<UIScrollView>();
		// 设置Cull  
		_scrollView.GetComponent<UIPanel>().cullWhileDragging = true;
		_grid = this.transform.GetComponent<UIGrid>();
		float cellWidth = _grid.cellWidth;
		float cellHeight = _grid.cellHeight;
		_posParam = new Vector4(cellWidth,cellHeight,_grid.arrangement == UIGrid.Arrangement.Horizontal ? 1 : 0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值