Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void IncreaseBuffStat<T>(T scriptableObject, string variableName, float amount) where T : ScriptableObject
- {
- if (scriptableObject == null) return;
- Type type = scriptableObject.GetType();
- FieldInfo field = type.GetField(variableName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
- if (field != null && field.FieldType == typeof(float))
- {
- float currentValue = (float)field.GetValue(scriptableObject);
- field.SetValue(scriptableObject, currentValue + amount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment