1
\$\begingroup\$

I have a ScrollView. It has children, most of which I want to scroll, but some of which I want to remain still. Think of something along the lines of a spreadsheet where the title rows/columns don't move.

I have somewhat succeeded, as the GameObjects I want to stay in their place do, but they are fighting the ScrollView to move. It forces them to jitter every time I scroll. Here is my current code:

private Vector3 originalPosition = Vector3.zero;

private IEnumerator Start()
{
    yield return new WaitWhile(() => transform.position == Vector3.zero);
    originalPosition = transform.position;
}

private void OnGUI()
{
    if (originalPosition == Vector3.zero)
    {
        return;
    }
    transform.position = originalPosition;
}

What is causing it to jitter? And how can I fix it?

(The reason I am waiting to start updating is because my GameObject originally thinks its position is (0, 0, 0)...not sure why. Maybe its related?)

\$\endgroup\$

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.