private Component[] SearchComponent(GameObject gmo, ESearchMode mode) { Component[] all = null; if (mode == ESearchMode.ComponentAll) { all = gmo.GetComponentsInChildren <Component>(true); } else { all = gmo.GetComponentsInChildren <MonoBehaviour>(true); } return(all); }
/// <summary> /// Search /// </summary> void OnGUI() { _searchComponentFilter = EditorGUILayout.TextField("TypeFilter", _searchComponentFilter); EditorGUILayout.BeginHorizontal(); var oldSearchMode = _searchMode; _searchMode = (ESearchMode)(EditorGUILayout.EnumPopup(_searchMode)); if (oldSearchMode != _searchMode) { this.Clear(); List <GameObject> parentObj = this.GetAllRootGameObjects(); EditorApplication.isPaused = true; CreateTypeDictionary(parentObj); } if (GUILayout.Button("Search", GUILayout.Width(150))) { List <GameObject> parentObj = this.GetAllRootGameObjects(); EditorApplication.isPaused = true; CreateTypeDictionary(parentObj); } EditorGUILayout.EndHorizontal(); // EditorGUILayout.HelpBox("If root gameObject is disabled, couldn't count child objects..", MessageType.Info); EditorGUILayout.HelpBox("If you don't save scene, this doesn't work..", MessageType.Info); EditorGUILayout.LabelField("GameObject " + _snapObjectNum); EditorGUILayout.LabelField("ActiveNum " + _activeObjectNum); EditorGUILayout.LabelField(""); var oldSortTYpe = _sortType; _sortType = (ESortType)EditorGUILayout.EnumPopup(_sortType); if (oldSortTYpe != _sortType) { this.SortComponents(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Type"); EditorGUILayout.LabelField("active", GUILayout.Width(50)); EditorGUILayout.LabelField("all", GUILayout.Width(50)); EditorGUILayout.LabelField("", GUILayout.Width(20)); EditorGUILayout.EndHorizontal(); _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.Height(150)); if (_typeCntList != null) { foreach (var type in _typeCntList) { if (type == null) { continue; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(type.type.ToString())) { _currentSelectType = type.type; this._hasComponentGameObjectList = GetHaveComponentObjects(this.GetAllRootGameObjects(), type.type); } EditorGUILayout.LabelField(type.activeCnt.ToString(), GUILayout.Width(50)); EditorGUILayout.LabelField(type.allCnt.ToString(), GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); /// gameobject list; if (_hasComponentGameObjectList != null && _currentSelectType != null) { EditorGUILayout.LabelField(""); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(_currentSelectType.ToString() + " Compoent Objects"); _outputType = (EOutputList)(EditorGUILayout.EnumPopup(_outputType, GUILayout.Width(120))); EditorGUILayout.EndHorizontal(); _scrollGameObjectListPos = EditorGUILayout.BeginScrollView(_scrollGameObjectListPos); foreach (var gmo in _hasComponentGameObjectList) { if (gmo) { switch (_outputType) { case EOutputList.AllObject: EditorGUILayout.ObjectField(gmo, typeof(GameObject)); break; case EOutputList.ActiveOnly: if (gmo.activeInHierarchy) { EditorGUILayout.ObjectField(gmo, typeof(GameObject)); } break; case EOutputList.NotActiveOnly: if (!gmo.activeInHierarchy) { EditorGUILayout.ObjectField(gmo, typeof(GameObject)); } break; } } } EditorGUILayout.EndScrollView(); } }