void ChangeValue(float change) { // This gets a bit complicated because we want to deal with both ints and floats float newDictVal = 0; float newFieldVal = 0; // Do the actual alteration if (dict) { newDictVal = dict.GetFloat(key) + change; } if (field.member != "") { newFieldVal = field.GetFloat() + change; } if (loopMaxAndMin) { if (((newDictVal > maximum && increasePerSecond > 0) || (newDictVal < minimum && increasePerSecond < 0)) || ((newFieldVal > maximum && increasePerSecond > 0) || (newFieldVal < minimum && increasePerSecond < 0))) { increasePerSecond = -increasePerSecond; } print(newFieldVal + " " + change); } else if (limitToMaxAndMin) { newDictVal = newDictVal.LimitToRange(minimum, maximum); newFieldVal = newFieldVal.LimitToRange(minimum, maximum); } // Set the values, making sure we use correct type if (dict) { if (dict.Get(key) is int) { dict.Set(key, (int)newDictVal); } else { dict.Set(key, newDictVal); } } if (field.member != "") { if (field.GetObject() is int) { field.SetValue((int)newFieldVal); } else { field.SetValue(newFieldVal); } } }
void Update() { float change = 0; if (oncePerClick) { if (Input.GetButtonDown(input)) { change = stTools.GetAxisNorm(input) * delta; } } else { if (softenInput) { change = Input.GetAxis(input) * delta; } else { change = stTools.GetAxisNorm(input) * delta; } } if (change != 0) { float newVal; if (dict) { newVal = dict.GetFloat(key) + change; if (limits) { newVal = newVal.LimitToRange(minLimit, maxLimit); } dict.Set(key, newVal); } if (field.member != "") { newVal = field.GetFloat() + change; if (limits) { newVal = newVal.LimitToRange(minLimit, maxLimit); } field.SetValue(newVal); } } }
void Alter() { if (!enabled) { return; } // This gets a bit complicated because we want to deal with both ints and floats float newDictVal = 0; float newFieldVal = 0; // Do the actual alteration switch (operation) { case OperationEnum.Add: if (dict) { newDictVal = dict.GetFloat(key) + value; } if (field.member != "") { newFieldVal = field.GetFloat() + value; } break; case OperationEnum.SetTo: if (dict) { newDictVal = value; } if (field.member != "") { newFieldVal = value; } break; case OperationEnum.Multiply: if (dict) { newDictVal = dict.GetFloat(key) * value; } if (field.member != "") { newFieldVal = field.GetFloat() * value; } break; } // Set the values, making sure we use correct type if (dict) { if (dict.Get(key) is int) { dict.Set(key, (int)newDictVal); } else { dict.Set(key, newDictVal); } } if (field.member != "") { if (field.GetObject() is int) { field.SetValue((int)newFieldVal); } else { field.SetValue(newFieldVal); } } }