Пример #1
0
    IEnumerator ButtonHoverExit(ButtonPad buttonInstance)
    {
        //for node size
        float vel = 0f;

        //for node movement
        float moveVel   = 0.0f;
        float moveSpeed = 4.0f;
        float current   = 0f;
        float target    = .25f * buttonInstance.textStyle.textSize;

        while (current < target - .01f)
        {
            Color color = buttonInstance.GetComponent <MeshRenderer>().material.color;
            color.a = Mathf.SmoothDamp(color.a, .17f, ref vel, .02f);
            buttonInstance.GetComponent <MeshRenderer>().material.color = color;

            current = Mathf.SmoothDamp(current, target, ref moveVel, moveSpeed * Time.deltaTime);



            buttonInstance.node.transform.Translate(0f, 0f, -current);

            yield return(null);
        }
    }
Пример #2
0
    IEnumerator ButtonHover(ButtonPad buttonInstance)
    {
        //for node size
        float vel = 0.0f;

        //for node movement
        float moveVel   = 0.0f;
        float moveSpeed = 4.0f;
        float current   = 0f;
        float target    = .25f * buttonInstance.textStyle.textSize;

        Vector3 newPos;

        //changes color and moves button vector3.forward on "mouseover" (uses SmoothDamp)
        while (current < target - .01f)
        {
            Color color = buttonInstance.GetComponent <MeshRenderer>().material.color;
            color.a = Mathf.SmoothDamp(color.a, .55f, ref vel, .02f);
            buttonInstance.GetComponent <MeshRenderer>().material.color = color;


            current = Mathf.SmoothDamp(current, target, ref moveVel, moveSpeed * Time.deltaTime);



            buttonInstance.node.transform.Translate(0f, 0f, current);



            yield return(null);
        }
    }