ObjectExtension.cs 641 B

12345678910111213141516171819202122232425262728
  1. using UnityEngine;
  2. using UnityEditor;
  3. namespace UnityEditor.Timeline
  4. {
  5. static class ObjectExtension
  6. {
  7. public static bool IsSceneObject(this Object obj)
  8. {
  9. if (obj == null)
  10. return false;
  11. bool isSceneType = obj is GameObject || obj is Component;
  12. if (!isSceneType)
  13. return false;
  14. return !PrefabUtility.IsPartOfPrefabAsset(obj);
  15. }
  16. public static bool IsPrefab(this Object obj)
  17. {
  18. if (obj == null)
  19. return false;
  20. return PrefabUtility.IsPartOfPrefabAsset(obj);
  21. }
  22. }
  23. }