There is a vertical scrollbar from TK2D to Unity. It should reach with its lower edge to the lower button, top - to the top. When changing the resolution should adjust automatically.

If you just need to drag an object after another object, this works

Object for which we drag - topAnchor,

The object that we are dragging is bar

void Start() { Align(); } void Align() { bar.transform.position = new Vector3(bar.transform.position.x, topAnchor.GetComponent<Renderer>().bounds.min.y, bar.transform.position.z); } void LateUpdate() { if ((int)Tk2dGuiCamera.ScreenExtents.yMin != lastCamHeight) { lastCamHeight = Tk2dGuiCamera.ScreenExtents.yMin; Align(); } } 

But in this case, the task is somewhat different, we must not drag the object after another, but stretch it between the other two. How to do it?

    1 answer 1

    This task should not be fixed by code.

    This task should be solved with the correct anchors on the canvas.

    So that when changing the resolution there are no problems - put the canvas in the scale mode that suits your needs.

    Do not forget to increase the default resolution of the canvas twice.

    • @ Alexey Shimansky There is no canvas. This is a 2dToolkit. - Dmitrii
    • one
      @Dmitrii - Alexey Shimansky
    • @Andrew There is no canvas. This is 2DToolkit. If possible, I would like to solve the problem with the code - Dmitrii
    • Then the task is purely mathematical. Put the anchor at the tulkit on the bottom (well, il on the top, it doesn't matter). Calculate how much from one button to another. Then scale vertically your scroll based on the original height and the one that you just got. Although this is an unnecessary perversion, as for me. - Andrew