summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/UICommon/XUIPanel.cs
blob: dd2b0f28105065a4f87e48fec7d6cd016d0f454d (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using UILib;
using UnityEngine;
using System;

public class XUIPanel : XUIObject, IXUIPanel
{
    protected override void OnAwake()
    {
		base.OnAwake();        
        if (null == m_uiPanel)        
        {
            m_uiPanel = GetComponent<UIPanel>();
            if (null == m_uiPanel)
            {
                Debug.LogError("null == m_uiPanel");
            }
        }
        m_uiPanel.onClipMove += OnMove;
    }

    public void OnMove(UIPanel panel)
    {
        if (onMoveDel != null) onMoveDel();
    }

    public void SetSize(float width, float height)
    {
        Vector4 origin = m_uiPanel.baseClipRegion;
        m_uiPanel.baseClipRegion = new Vector4(origin.x, origin.y, width, height);
    }

    public void SetCenter(float width, float height)
    {
        Vector4 origin = m_uiPanel.baseClipRegion;
        m_uiPanel.baseClipRegion = new Vector4(width, height, origin.x, origin.y);
    }
    public Vector4 GetBaseRect()
    {
        return m_uiPanel.baseClipRegion;
    }

    public void SetAlpha(float a)
    {
        m_uiPanel.alpha = a;
    }

    public float GetAlpha()
    {
        return m_uiPanel.alpha;
    }

    public void SetDepth(int d)
    {
    	m_uiPanel.depth = d;
    }

    public int GetDepth()
    {
    	return m_uiPanel.depth;
    }

    public Vector2 offset
    {
        get
        {
            return m_uiPanel.clipOffset;
        }
        set
        {
            m_uiPanel.clipOffset = value;
        }
    }

    public bool IsVisible(GameObject go)
    {
        return m_uiPanel.IsVisible(go.GetComponent<UIWidget>());
    }

    public Vector4 ClipRange
    {
        get
        {
            return m_uiPanel.baseClipRegion;
        }
        set
        {
            m_uiPanel.baseClipRegion = value;
        }
    }

    public Vector2 softness
    {
        get
        {
            return m_uiPanel.clipSoftness;
        }
        set
        {
            m_uiPanel.clipSoftness = value;
        }
    }

    public UIPanel m_uiPanel = null;

    public Action onMoveDel { get; set; }

    public Component UIComponent { get { return m_uiPanel; } }


    public static IXUIPanel GetPanel(UIPanel panel)
    {
        if (panel == null)
            return null;

        XUIPanel xPanel = panel.GetComponent<XUIPanel>();
        if (xPanel == null)
        {
            xPanel = panel.gameObject.AddComponent<XUIPanel>();
        }

        return xPanel;
    }
}