Example #1
0
    private IEnumerator SetMapPositionToAciveButton()
    {
        yield return(new WaitForSeconds(0.1f));

        if (sRect)
        {
            int   bCount       = biomesCount;
            float contentSizeY = content.sizeDelta.y / (bCount) * (bCount - 1.0f);
            float relPos       = content.InverseTransformPoint(ActiveButton.transform.position).y; // Debug.Log("contentY : " + contentSizeY +  " ;relpos : " + relPos + " : " + relPos / contentSizeY);
            float vpos         = (-contentSizeY / (bCount * 2.0f) + relPos) / contentSizeY;        //

            SimpleTween.Cancel(gameObject, false);
            float start = sRect.verticalNormalizedPosition;

            SimpleTween.Value(gameObject, start, vpos, 0.25f).SetOnUpdate((float f) => { sRect.verticalNormalizedPosition = Mathf.Clamp01(f); });
            //sRect.verticalNormalizedPosition = Mathf.Clamp01(vpos); // Debug.Log("vpos : " + Mathf.Clamp01(vpos));
        }
        else
        {
            Debug.Log("no scrolling rect");
        }
    }