summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/UICommon/XUICommon.cs
blob: 09ffcc9731f2f02d1c387b2e0dae5ef40b2c5cd0 (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
using UnityEngine;
using XUtliPoolLib;

public class XUICommon : XSingleton<XUICommon>
{
    public UIPanel m_uiRootPanel;
    public UIPanel m_inVisiablePanel;
    public void Init(Transform uiRoot)
    {
        m_uiRootPanel = uiRoot.GetComponent<UIPanel>();
        m_uiRootPanel.updateFrame = 3;

        m_inVisiablePanel = null;
        Transform inVisablePanel = m_uiRootPanel != null ? m_uiRootPanel.transform.Find("InVisiblePanel") : null;
        if (inVisablePanel != null)
        {
            m_inVisiablePanel = inVisablePanel.GetComponent<UIPanel>();
        }
    }
    public void SetRootPanelUpdateFreq(int count)
    {
        m_uiRootPanel.updateFrame = count;
    }
    public static void CloneTplTweens(GameObject tpl, GameObject clone)
    {
        if (clone.GetComponent<UIPlayTween>() != null) return;

        UIPlayTween[] tweens = tpl.GetComponents<UIPlayTween>();

        for (int i=0;i<tweens.Length;++i)
        {
            UIPlayTween tween = tweens[i];
            UIPlayTween t = clone.AddComponent<UIPlayTween>();
            t.tweenGroup = tween.tweenGroup;
            t.trigger = tween.trigger;
            t.playDirection = tween.playDirection;
            t.resetIfDisabled = tween.resetIfDisabled;
            t.resetOnPlay = tween.resetOnPlay;
            t.ifDisabledOnPlay = tween.ifDisabledOnPlay;
            t.disableWhenFinished = tween.disableWhenFinished;
        }

        TweenScale[] scales = tpl.GetComponents<TweenScale>();

        for (int i = 0; i < scales.Length; ++i)
        {
            TweenScale tweenScale = scales[i];
            TweenScale s = clone.AddComponent<TweenScale>();
            s.from = tweenScale.from;
            s.to = tweenScale.to;
            s.style = tweenScale.style;
            s.animationCurve = tweenScale.animationCurve;
            s.duration = tweenScale.duration;
            s.delay = tweenScale.delay;
            s.tweenGroup = tweenScale.tweenGroup;
            s.ignoreTimeScale = tweenScale.ignoreTimeScale;

            s.enabled = false;
        }
    }

   
}