Exemplo n.º 1
0
    void Update()
    {
        var trt        = Target.GetComponent <RectTransform>();
        var desiredPos = DesiredRelPos * trt.rect.size;
        var worldPos   = trt.TransformPoint(desiredPos);
        var objPos     = rt.InverseTransformPoint(worldPos);

        if (!float.IsInfinity(objPos.x) && !float.IsInfinity(objPos.y))
        {
            rt.localPosition = Vector3.Lerp(rt.localPosition, objPos, PosSpeed).withZ(0);
        }
        rt.localScale = Vector3.Lerp(rt.localScale, Vector3.zero, ScaleSpeed);
    }