Ejemplo n.º 1
0
    IEnumerator BookOpen()
    {
        bookleft.gameObject.transform.SetSiblingIndex(4);
        bookleft.localPosition = new Vector3(bookleft.rect.width, 0, 0);
        var timer = 0f;
        var flag  = false;

        bookleft.pivot = new Vector2(0, 0.5f);
        while (timer <= 1)
        {
            timer += Time.deltaTime * 0.25f;
            if (!flag)
            {
                if (timer < 0.5f)
                {
                    float angle = Mathf.LerpAngle(0f, 90f, timer * 2);
                    bookleft.eulerAngles = new Vector3(0, angle, 0);

                    bookr_maintex.color = Color.Lerp(color1, color2, timer * 2);
                }
                else
                {
                    flag = true;
                    bookl_maintex.texture  = booktex2;
                    bookleft.localPosition = new Vector3(-bookleft.rect.width * 2, 0, 0);
                    bookleft.pivot         = new Vector2(1, 0.5f);
                }
            }
            if (flag)
            {
                float angle = Mathf.LerpAngle(-90f, 0f, timer * 2 - 1);
                bookleft.eulerAngles = new Vector3(0, angle, 0);

                bookl_maintex.color = Color.Lerp(color1, color2, timer * 2 - 1);
            }
            yield return(new WaitForEndOfFrame());
        }
        yield return(new WaitForEndOfFrame());

        BookOpener = false;
        textScript.BookReadStart();
    }