Ejemplo n.º 1
0
    public void Init(List <Vector2> ePts, float eTimeS = 0, float eTimeD = 1)
    {
        rectTrans = GetComponent <RectTransform>();
        rectTrans.anchoredPosition = Vector2.zero;

        txt = GetComponent <Text>();

        bezierPts = new List <Vector2>(ePts);

        if (ePts.Count == 1)
        {
            transform.position = ePts[0];
            return;
        }

        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }

        timeStart    = eTimeS;
        timeDuration = eTimeD;

        state = eFState.pre;
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (state == eFState.idle)
        {
            return;
        }

        float u  = (Time.time - timeStart) / timeDuration;
        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)
        {
            state       = eFState.pre;
            txt.enabled = false;
        }
        else
        {
            if (u >= 1)
            {
                uC    = 1;
                state = eFState.post;
                if (reportFinishTo != null)
                {
                    reportFinishTo.SendMessage("FSCallback", this);
                    Destroy(gameObject);
                }
                else
                {
                    state = eFState.idle;
                }
            }
            else
            {
                state       = eFState.active;
                txt.enabled = true;
            }
        }

        Vector2 pos = Utils.Bezier(uC, bezierPts);

        rectTrans.anchorMin = rectTrans.anchorMax = pos;
        if (fontSizes != null && (fontSizes.Count > 0))
        {
            int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
            GetComponent <Text>().fontSize = size;
        }
    }