ObjectExtensions.cs 718 B

123456789101112131415161718192021222324
  1. using UnityEngine;
  2. namespace GitMerge
  3. {
  4. public static class ObjectExtensions
  5. {
  6. /// <summary>
  7. /// Get a fine, readable type string. Doesn't really need to be a Component extension method.
  8. /// Example: UnityEngine.BoxCollider => BoxCollider
  9. /// </summary>
  10. /// <param name="o">The object whose type we want to display</param>
  11. /// <returns>The well readable type string</returns>
  12. public static string GetPlainType(this object o)
  13. {
  14. var s = o.GetType().ToString();
  15. var i = s.LastIndexOf('.');
  16. if (i >= 0)
  17. {
  18. s = s.Substring(i + 1);
  19. }
  20. return s;
  21. }
  22. }
  23. }