Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using System;
  6.  
  7. public static class GetAllBrothers_Object
  8. {
  9. public static GameObject[] GetAllBrothers(this GameObject thisObj,bool getInvalid = false){
  10. Transform parent = thisObj.transform.parent;
  11. Transform[] brotrans = new Transform[parent.childCount];
  12. if(parent != null){
  13. for(int i=0;parent.childCount>i;i++)brotrans[i]=parent.GetChild(i);
  14. }
  15. return brotrans.Cast<Transform>().Where(x=>x!=thisObj.transform).Where(x=>x.gameObject.activeInHierarchy==true||getInvalid==true).Select(x=>x.gameObject).ToArray();
  16. }
  17. }
  18. public static class GetAllBrothers_Component
  19. {
  20. public static GameObject[] GetAllBrothers(this Component thisCom,bool getInvalid = false){
  21. Transform parent = thisCom.transform.parent;
  22. Transform[] brotrans = new Transform[parent.childCount];
  23. if(parent != null){
  24. for(int i=0;parent.childCount>i;i++)brotrans[i]=parent.GetChild(i);
  25. }
  26. return brotrans.Cast<Transform>().Where(x=>x!=thisCom.transform).Where(x=>x.gameObject.activeInHierarchy==true||getInvalid==true).Select(x=>x.gameObject).ToArray();
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement