I want to change my values using a method. Values change in method but not outside of it they remain same. I am trying to change these value by method 1st time so I have no idea about it they can change or not. any reference or help :) CODE :
Method :-
void WeaponUpdateMethod (int objUpdateValue, float time, string updateMoney, string saveData, float sliderValue)
{
buttonClick.Play ();
int t = objUpdateValue;
if (t < 1 && totalMoney > 5000) {
t = 1;
totalMoney -= 5000;
time = 12f;
} else if (t != 2 && t < 2 && totalMoney > 10000) {
t = 2;
totalMoney -= 10000;
time = 15f;
} else if (t != 3 && t < 3 && totalMoney > 14000) {
t = 3;
totalMoney -= 14000;
time = 17f;
} else if (t != 4 && t < 4 && totalMoney > 25000) {
t = 4;
totalMoney -= 25000;
time = 20f;
}
if (t == 0) {
updateMoney = "" + 5000;
} else if (t == 1) {
updateMoney = "" + 10000;
} else if (t == 2) {
updateMoney = "" + 14000;
} else if (t == 3) {
updateMoney = "" + 25000;
} else if (t == 4) {
updateMoney = "full";
}
PlayerPrefs.SetInt (saveData, t);
PlayerPrefs.SetInt ("totalMoney", totalMoney);
PlayerPrefs.Save ();
sliderValue = t;
objUpdateValue = t;
print (objUpdateValue);
print(objUpdateValue+" from method");
}
Using Here :-
public void UpgradeSpeedUp ()
{
// to upgrade speedUp
WeaponUpdateMethod (speedUpUpdateValue, ManageSingleShotPowers.speedUpTime, speedUpUpdateMoney.text, "spedUpUpdate", speedUpSlider.value);
print(speedUpUpdateValue +" from calling");
}
In C#, parameters are passed in by value by default. You have to specify the parameters to be passed in by reference. You do that by using the keyword ref in front of your parameters, for example, ref int objUpdateValue.