Eonirr

Untitled

May 14th, 2025
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. public static void CopyValues<T>(T source, T target) where T : ScriptableObject
  2. {
  3. if (source == null || target == null || source.GetType() != target.GetType()) return;
  4.  
  5. FieldInfo[] fields = source.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
  6.  
  7. foreach (FieldInfo field in fields)
  8. {
  9. object value = field.GetValue(source);
  10. field.SetValue(target, value);
  11. }
  12. }
  13.  
Advertisement
Add Comment
Please, Sign In to add comment