Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Linq;
- using System;
- public static class GetAllBrothers_Object
- {
- public static GameObject[] GetAllBrothers(this GameObject thisObj,bool getInvalid = false){
- Transform parent = thisObj.transform.parent;
- Transform[] brotrans = new Transform[parent.childCount];
- if(parent != null){
- for(int i=0;parent.childCount>i;i++)brotrans[i]=parent.GetChild(i);
- }
- return brotrans.Cast<Transform>().Where(x=>x!=thisObj.transform).Where(x=>x.gameObject.activeInHierarchy==true||getInvalid==true).Select(x=>x.gameObject).ToArray();
- }
- }
- public static class GetAllBrothers_Component
- {
- public static GameObject[] GetAllBrothers(this Component thisCom,bool getInvalid = false){
- Transform parent = thisCom.transform.parent;
- Transform[] brotrans = new Transform[parent.childCount];
- if(parent != null){
- for(int i=0;parent.childCount>i;i++)brotrans[i]=parent.GetChild(i);
- }
- return brotrans.Cast<Transform>().Where(x=>x!=thisCom.transform).Where(x=>x.gameObject.activeInHierarchy==true||getInvalid==true).Select(x=>x.gameObject).ToArray();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement