public void ListFilteredObjectsMethod() { for (int i = 0; i < filteredGameObjects.Count; i++) { //Create a button for detect every object. if (GUILayout.Button(filteredGameObjects[i].gameObject.name)) { focusObj = filteredGameObjects[i].transform; CallbackMethods callbackmethods = CreateInstance <CallbackMethods>(); //Create new generic menu. GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Select"), false, callbackmethods.SelectObjCallback); menu.AddItem(new GUIContent("Focus"), false, callbackmethods.FocusCallback); menu.AddItem(new GUIContent("Remove"), false, callbackmethods.RemoveFromFilteredCallback); menu.AddItem(new GUIContent("Rename"), false, callbackmethods.NewNameCallback); menu.ShowAsContext(); } } //Remove duplicates. filteredGameObjects = filteredGameObjects.Distinct().ToList(); }
void OnGUI() { RectValues(); //Filter methods section rect values. filterMethodSectionRect = new Rect(0, Screen.height / 10, Screen.width, Screen.height); GUILayout.BeginArea(headerSectionRect); // Write a header. GUILayout.Label("Hierarchy Assistant V1.0", guiSkin.label); GUILayout.EndArea(); GUILayout.BeginArea(mainFunctionTabSectionRect); GUILayout.EndArea(); #region Main pages. // if page one is active GUILayout.BeginArea(filterMethodSectionRect, EditorStyles.inspectorFullWidthMargins); GUILayout.Space(5f); methodSectionshowPosition = EditorGUILayout.Foldout(methodSectionshowPosition, "Filter Methods", EditorStyles.boldFont); GUILayout.Space(5f); if (methodSectionshowPosition) { //Increase indent level; EditorGUI.indentLevel++; filterMethod_mainMethods_sub_foldout = EditorGUILayout.Foldout(filterMethod_mainMethods_sub_foldout, "Main Methods", EditorStyles.boldFont); if (filterMethod_mainMethods_sub_foldout) { toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings); } GUILayout.Space(5f); filterMethod_secondaryMethods_sub_foldout = EditorGUILayout.Foldout(filterMethod_secondaryMethods_sub_foldout, "Secondary Method", EditorStyles.boldFont); if (filterMethod_secondaryMethods_sub_foldout) { GUILayout.BeginHorizontal(); if (GUILayout.Button("...")) { CallbackMethods callbackmethods = CreateInstance <CallbackMethods>(); GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Add Static Objects"), false, callbackmethods.AddStaticObjectsCallback); //menu.AddItem(new GUIContent("Add Inactive Objects(Hierarchy)"), false, callbackmethods.AddInactiveInHierarchyCallback); menu.ShowAsContext(); } // GUILayout.Button("Add Inactive Objects"); GUILayout.EndHorizontal(); } //Normalize indent level; EditorGUI.indentLevel--; GUILayout.Space(5f); } GUILayout.Space(5f); methodSettingsSectionPosition = EditorGUILayout.Foldout(methodSettingsSectionPosition, "Filter Settings", EditorStyles.boldFont); #region filtering methods if (methodSettingsSectionPosition) { //Filter method with tag. if (toolbarInt == 0) { tag_method_str = EditorGUILayout.TagField("Select tag", tag_method_str); GUILayout.Space(5f); if (GUILayout.Button("Add to filtered objects")) { MainFilteringMethods mainfilteringmethods = CreateInstance <MainFilteringMethods>(); mainfilteringmethods.WithTag(); } } //Filter method with layer. if (toolbarInt == 1) { layer_method_int = EditorGUILayout.LayerField("Select Layer", layer_method_int); GUILayout.Space(5f); if (GUILayout.Button("Add to filtered objects")) { MainFilteringMethods mainfilteringmethods = CreateInstance <MainFilteringMethods>(); mainfilteringmethods.WithLayer(); } } } #endregion GUILayout.Space(5f); filteredObjectsSectionPosition = EditorGUILayout.Foldout(filteredObjectsSectionPosition, "Filtered Objects", EditorStyles.boldFont); //if filtered object section foldout is open: if (filteredObjectsSectionPosition) { //Create new scrool view. scrollposition = GUILayout.BeginScrollView(scrollposition, GUILayout.Height(150)); ListFilteredObjects listfilteredobjs = CreateInstance <ListFilteredObjects>(); //Call method which lists filtered objects in ListFilteredObjects class. listfilteredobjs.ListFilteredObjectsMethod(); GUILayout.Space(5f); GUILayout.BeginHorizontal(); GUI.backgroundColor = Color.red; if (GUILayout.Button("Remove all")) { filteredGameObjects.Clear(); //Clear filtered objects. } GUI.backgroundColor = Color.white; if (GUILayout.Button("Select all")) { GameObject[] selectallobjs = filteredGameObjects.ToArray(); Selection.objects = selectallobjs; } //Operations window. if (GUILayout.Button("...")) { CallbackMethods callbackmethods = CreateInstance <CallbackMethods>(); //Create new generic menu. GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Create New Parent"), false, callbackmethods.NewParentCallback); menu.AddItem(new GUIContent("Replace New Prefab"), false, callbackmethods.ReplaceNewPrefabCallback); menu.ShowAsContext(); } GUILayout.EndScrollView(); // this.Repaint(); GUILayout.EndHorizontal(); } GUILayout.EndArea(); #endregion }