Beispiel #1
0
 // Update is called once per frame
 void Update()
 {
     if (Mathf.Abs(targetAngle - angle) < 0.01f)
     {
         return;
     }
     else if (Mathf.Abs(targetAngle - angle) > accelSection)
     {
         if (targetAngle > angle)
         {
             angle += maxRotateSpeed * Time.deltaTime;
         }
         else
         {
             angle -= maxRotateSpeed * Time.deltaTime;
         }
     }
     else
     {
         float rotateSpeed = Mathf.Lerp(minRotateSpeed, maxRotateSpeed, Mathf.Abs(targetAngle - angle) / accelSection);
         if (targetAngle > angle)
         {
             angle += rotateSpeed * Time.deltaTime;
         }
         else
         {
             angle -= rotateSpeed * Time.deltaTime;
         }
     }
     transform.localPosition = Publics.CirclePos(radius, angle);
     Display();
 }
Beispiel #2
0
 public void SetButton(float _radius, float _angle, float _border, int _menuSize)
 {
     radius = _radius;
     angle = _angle;
     border = _border;
     menuSize = _menuSize;
     transform.localPosition = Publics.CirclePos(radius, angle);
     targetAngle = angle;
     Display();
 }
Beispiel #3
0
 void Display()
 {
     for (int idx = 0; idx < buttonCount; idx++)
     {
         buttons[idx].localPosition = Publics.CirclePos(UIRadius, scrollSpeed * buttonPosition[idx]);
         int order = menuSize - Mathf.Abs(buttonPosition[idx]);
         order = Mathf.Clamp(order, 0, menuSize);
         buttons[idx].GetComponent <Canvas>().sortingOrder = order;
         //buttons[idx].GetComponent<CanvasRenderer>().SetAlpha((float)order / menuSize);
         var buttonRenderers = buttons[idx].GetComponentsInChildren <CanvasRenderer>();
         foreach (CanvasRenderer renderer in buttonRenderers)
         {
             renderer.SetAlpha((float)order / menuSize);
         }
     }
 }
Beispiel #4
0
    public IEnumerator Animate(float start, float end, float angle, float time, float waittime = 0f)
    {
        yield return(new WaitForSeconds(waittime));

        float myTime = 0f;

        while (myTime < time)
        {
            myTime += Time.deltaTime;
            float   x        = ac.Evaluate(myTime / time);
            Vector3 startPos = Publics.CirclePos(start, angle);
            Vector3 endPos   = Publics.CirclePos(end, angle);
            transform.localPosition = Vector3.Lerp(startPos, endPos, x);
            yield return(null);
        }
        transform.localPosition = Publics.CirclePos(end, angle);
        if (end == 0f)
        {
            gameObject.SetActive(false);
        }
    }