Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. private static Action<SerializedProperty, T> GetDefaultPropertySetter<T>()
  2. {
  3. var clrType = typeof (T);
  4.  
  5. if (clrType == typeof (string)) {
  6. return (Action<SerializedProperty, T>) Convert.ChangeType(
  7. new Action<SerializedProperty, string>(
  8. (p, s) => p.stringValue = s
  9. ),
  10. typeof (Action<SerializedProperty, T>));
  11. }
  12. if (clrType == typeof (int)) {
  13. return (Action<SerializedProperty, T>) Convert.ChangeType(
  14. new Action<SerializedProperty, int>(
  15. (p, s) => p.intValue = s
  16. ),
  17. typeof (Action<SerializedProperty, T>));
  18. }
  19. if (clrType == typeof (float)) {
  20. return (Action<SerializedProperty, T>) Convert.ChangeType(
  21. new Action<SerializedProperty, float>(
  22. (p, s) => p.floatValue = s
  23. ),
  24. typeof (Action<SerializedProperty, T>));
  25. }
  26. throw new ArgumentException("No default field drawer specified for " + clrType.FullName);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement