Example #1
0
    void Update()
    {
        if (RectTransformLerper.Lerpee == null)
        {
            return;
        }

        if (!ImageContainer.HasComponent <RectMask2D>())
        {
            ImageContainer.gameObject.AddComponent <RectMask2D>();
        }

        if (ToolImageA.sprite != Image.sprite)
        {
            ToolImageA.sprite = ToolImageB.sprite =
                Image.sprite;

            RectTransformLerper.A.sizeDelta = RectTransformLerper.B.sizeDelta =
                RectTransformLerper.Lerpee.sizeDelta;
        }

        RectTransformLerper.LerpFactor =
            (ImageContainer.rect.width - ToolAContainer.rect.width) /
            (ToolBContainer.rect.width - ToolAContainer.rect.width);
    }