Home > other >  Slider the value going wrong when defined the value outside
Slider the value going wrong when defined the value outside

Time:04-17

I had defined the value outside the slider, but when I put the value in the slider the value go wrong. any ideas?

var j3 = sp33;

sldertag[1].onValueChanged.AddListener((v) =>
{
  if (v < j3 )
  {
  float deta = j3 - v;
  join.transform.Rotate(deta, 0, 0);
  j3 = v;
               }
           });

CodePudding user response:

You are Passing Reference Types by Value, you need to Passing Reference Types by Reference.

try this

void Setslider(ref float Listener, ref float Passvalue){
  if (Listener < Passvalue )
  {
     float deta = Passvalue - Listener;
     join.transform.Rotate(deta, 0, 0);
     Passvalue = Listener;
  }
           };

Then put it in.

  • Related