chenxin
2020-12-03 0bc89b87a59c3f1f394a54c0901868084463cf28
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
using System.Drawing;
using UnityEngine;
using UnityEngine.UI;
using EnhancedUI.EnhancedScroller;
using TMPro;
using DG.Tweening;
public class FinalPanelItem : EnhancedScrollerCellView
{
    public Text playerNameTxt;
    public TextMeshProUGUI playerScoreTxt;
    public TextMeshProUGUI indexTxt;
 
    public Image icon;
    public Image backGround;
 
    private RectTransform rt;
 
    /// <summary>
    /// Start is called on the frame when a script is enabled just before
    /// any of the Update methods is called the first time.
    /// </summary>
    void Awake()
    {
        offect = Vector3.zero;
        rt = transform.GetComponent<RectTransform>();
    }
 
    Vector3 offect;
    public void SetData(FinalPanelItemData data)
    {
        playerNameTxt.text = data.playerName;
        playerScoreTxt.text = data.score.ToString();
        if (data.spriteIcon != null)
        {
            if (!icon.gameObject.activeSelf) icon.gameObject.SetActive(true);
            icon.sprite = data.spriteIcon;
            indexTxt.text = "";
        }
        else
        {
            icon.gameObject.SetActive(false);
            indexTxt.text = data.index.ToString();
        }
        backGround.sprite = data.spriteBackGround;
        if (rt != null)
        {
            offect.x = rt.anchoredPosition3D.x;
            offect.y = rt.anchoredPosition3D.y;
 
            rt.anchoredPosition3D = offect;
        }
    }
 
    public void SetPos()
    {
        backGround.rectTransform.anchoredPosition = new UnityEngine.Vector2(720, 0);
    }
 
    public void PlayDoTween(float duration)
    {
        //Sequence agentTweenSeq = DOTween.Sequence();
        //agentTweenSeq.Join(backGround.rectTransform.DOAnchorPosX(0, duration));
        backGround.rectTransform.DOAnchorPosX(0, duration);
    }
}