Пример #1
0
 // Use this for initialization
 void Start()
 {
     myEndAnimationMethod = endAnim;
     myoutside            = myblackbordPosOutside.position;
     myinside             = myblackbordPosInside.position;
     myPaper.gameObject.SetActive(false);
     myblackbord.gameObject.SetActive(false);
     PosX = myblackMenuShakeSide.position.x;
     PosY = myblackMenuShakeSide.position.y;
     PosZ = myblackMenuShakeSide.position.z;
     MenuDown();
 }
Пример #2
0
    // AniObj object that moves, fromRightnow is the startPos, endRightnow is the endPos,
    //playAni is the bool value which control the animation play or not, method is when the animation ends call the method, speed is the speed of the animation
    void animationPanel(RectTransform AniObj, Vector3 fromRightnow, Vector3 endRightnow, ref bool playAni, EndAnimationDelegate method, float speed)
    {
        Vector3 direction = (endRightnow - fromRightnow).normalized;

        if (isFirst)
        {
            AniObj.position = fromRightnow;
            isFirst         = false;
            startTime       = Time.time;
            journeyLength   = Vector3.Distance(fromRightnow, endRightnow);
        }
        else if (isplay && isFirst == false)
        {
            float distCovered = (Time.time - startTime) * speed;
            float fracJourney = distCovered / journeyLength;
            AniObj.Translate(direction * Time.deltaTime * speed, Space.Self);

            if (fracJourney >= 1)
            {
                playAni = false;
                isplay  = false;
                isFirst = true;
                if (method != null)
                {
                    method();
                }
            }
        }
    }