summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/UI/LoopScrollView/LoopItemObject.cs
blob: dd3610e259ae6b8d232cdc210fc6f1f2a85187ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using UnityEngine;
using System.Collections;
using XUtliPoolLib;

/// <summary>
/// item对像的封装类LoopItemObject,不要求具体的item类来继承它。
/// 但我们要示具体的item对像一定要包含UIWidget组件。
/// </summary>
[System.Serializable]
public class LoopItemObject:ILoopItemObject
{
    /// <summary>
    /// The widget.
    /// </summary>
    public UIWidget widget;

    /// <summary>
    /// 本item,在实际整个scrollview中的索引位置,
    /// 即对就数据,在数据列表中的索引
    /// </summary>
    public int _dataIndex = -1;

    public int dataIndex
    {
        get { return _dataIndex; }
        set { _dataIndex = value; }
    }

    public bool isVisible()
    {
        LoopScrollView sc = NGUITools.FindInParents<LoopScrollView>(widget.gameObject);
        if (sc != null) return sc.IsVisible(this);
        return false;
    }

    public GameObject GetObj()
    {
        return widget != null ? widget.gameObject : null;
    }


    public void SetHeight(int height)
    {
        widget.height = height;
    }

}