You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
775 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. public class MyEditorUtils
  6. {
  7. [MenuItem("GameTools/遍历Hierarchy")]
  8. static void GetAllSceneObjectsWithInactive()
  9. {
  10. var allGos = Resources.FindObjectsOfTypeAll(typeof(GameObject));
  11. var previousSelection = Selection.objects;
  12. Selection.objects = allGos;
  13. var selectedTransforms = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab);
  14. Selection.objects = previousSelection;
  15. foreach (var trans in selectedTransforms)
  16. {
  17. if (trans.gameObject.layer == LayerMask.NameToLayer("MiniMap"))
  18. {
  19. Debug.Log(trans.name);
  20. }
  21. }
  22. }
  23. }