GameObjectUtils.cs 735 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using UnityEngine;
  3. namespace ExtensionMethods
  4. {
  5. public static class GameObjectUtils
  6. {
  7. public static bool IsBiologicalChildOf(this GameObject gameObject, GameObject parent)
  8. {
  9. return gameObject.transform.parent == parent.transform;
  10. }
  11. public static bool IsBiologicalChildOf(this GameObject gameObject, Transform parent)
  12. {
  13. return gameObject.transform.parent == parent;
  14. }
  15. public static bool IsBiologicalParentOf(this GameObject gameObject, GameObject child)
  16. {
  17. return gameObject.transform == child.transform.parent;
  18. }
  19. public static bool IsBiologicalParentOf(this GameObject gameObject, Transform child)
  20. {
  21. return gameObject.transform == child.parent;
  22. }
  23. }
  24. }