matin saber
matin saber

Reputation: 52

how to use parameter to change scrollbar value in unity?

As u already know , The unity scrollbar value is between 0 to 1 I need a formula to change the value by the parameter I change in the inspector menu, like when I write 5 , the value changes to -5 to +5 , or when I write 10 the 0 to 1 changes to -10 to +10. I created one but its not using parameter Left_Eng = 2.0f * (2.0f * ScrollbarL.value - 1.0f) the formula changes 0 1 to -2 , +2 If anyone have an idea please tell me thanks a lot.

Upvotes: 1

Views: 853

Answers (1)

derHugo
derHugo

Reputation: 90580

So you want to map the range [0; 1] to [-x; x], right?

I think you basically already have it

  • [0;1]
  • * 2 => [0;2]
  • - 1 => [-1;1]
  • * x => [-x;x]

So together

var y = x * (2 * scrollValue - 1);

Upvotes: 1

Related Questions