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?)