summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XEditor/XCutSceneEditor/XCutSceneUI.cs
blob: ad881dae7399eab9b9f9fa6e83ef0aea105a935c (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
#if UNITY_EDITOR
using UnityEngine;
using XUtliPoolLib;
using XEditor;

public class XCutSceneUI : XSingleton<XCutSceneUI>
{
    public UISprite m_BG;
    public UILabel m_Text;
    public UILabel m_Skip;
    public UIPlayTween m_IntroTween;
    public UILabel m_Name;

    public GameObject _objUI;

    public override bool Init()
    {
        UIPanel p = NGUITools.CreateUI(false);
        
        _objUI = XResourceLoaderMgr.singleton.CreateFromPrefab("UI/Common/CutSceneUI") as GameObject;

        if (null != _objUI)
        {
            _objUI.transform.parent = p.transform;
            _objUI.transform.localPosition = new Vector3(0.0f, 0.0f, 0);
            _objUI.transform.localScale = new Vector3(1, 1, 1);
        }

        UIRoot rt = p.gameObject.GetComponent<UIRoot>();
        rt.scalingStyle = UIRoot.Scaling.FixedSize;
        rt.manualHeight = 1148;

        m_Text = _objUI.transform.Find("_canvas/DownBG/Text").GetComponent<UILabel>();

        m_Name = _objUI.transform.Find("_canvas/Intro/Name").GetComponent<UILabel>();
        m_IntroTween = _objUI.transform.Find("_canvas/Intro").GetComponent<UIPlayTween>();

        m_Text.text = "";

        _objUI.SetActive(false);
        m_IntroTween.gameObject.SetActive(false);
        return true;
    }

    public void SetText(string text)
    {
        m_Text.text = text;
    }

    public void SetVisible(bool visible)
    {
        _objUI.SetActive(visible);
    }

    public void SetIntroText(bool enabled, string name, string text, float x, float y)
    {
        if (!_objUI.activeInHierarchy) return;

        if (enabled)
        {
            m_Name.text = name;

            m_IntroTween.gameObject.transform.localPosition = new Vector2(x, y);
            m_IntroTween.tweenGroup = 0;
            m_IntroTween.ResetByGroup(true, 0);
            m_IntroTween.Play(true);

        }
        else 
        {
            m_IntroTween.tweenGroup = 1;
            m_IntroTween.ResetByGroup(true, 1);
            m_IntroTween.Play(true);
        }
    }
}
#endif