Hi,
is available a list of supported “filters”/“keys” for the Hierarchy search field?
I want to spot am “Invalid AABB result” probably due to a negative scale for a UGUI component but there are too many and i want to get a list of only rect transform UGI components (the top will be only those with a neg scale).
thank you.
You can search any component in the scene by entering the name of a component, so in your case it would be RectTransform.
1 Like
Thank you, i’m searching a way to do a search like: “field name”.value<x
I don’t think there is a built-in functionality like this, but you could probably write a simple editor script, just iterate through game objects on the scene → get component you want → check values → add to selection. Something like this:
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class cSelectWithValue : EditorWindow
{
[ MenuItem("Custom/Select with value") ]
public static void SelectWithValue()
{
Selection.objects = new Object[0];
m_Selection.Clear ();
m_ScrollPosition = new Vector2 ();
EditorWindow.GetWindow<cSelectWithValue>(false, "Select with value", true);
}
static string m_FieldValue = "";
static List<Object> m_Selection = new List<Object> ();
static Vector2 m_ScrollPosition = new Vector2();
void OnGUI()
{
EditorGUILayout.Space();
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.LabelField ("Search for value (less than): ");
m_FieldValue = EditorGUILayout.TextField (m_FieldValue);
EditorGUILayout.EndHorizontal ();
EditorGUILayout.Space ();
if( GUILayout.Button ("Select") )
{
float fValue = 0.0f;
if( float.TryParse( m_FieldValue, out fValue ) )
{
m_Selection.Clear();
FindAndSelect( fValue );
}
}
EditorGUILayout.BeginVertical ();
m_ScrollPosition = EditorGUILayout.BeginScrollView ( m_ScrollPosition );
if( m_Selection.Count > 0 )
{
for( int i = 0; i < m_Selection.Count; i++ )
{
EditorGUILayout.ObjectField(m_Selection[i].name, (Object)m_Selection[i], typeof(GameObject), true);
}
}
EditorGUILayout.EndScrollView ();
EditorGUILayout.EndVertical ();
}
static void FindAndSelect( float fValue )
{
GameObject[] objectsOnScene = GameObject.FindObjectsOfType<GameObject>();
for( int i = 0; i < objectsOnScene.Length; i++ )
{
RectTransform rectTransform = objectsOnScene[i].GetComponent<RectTransform>();
if( rectTransform && rectTransform.localScale.x < fValue )
{
m_Selection.Add( objectsOnScene[i] );
}
}
}
}
1 Like
Really nice i’ll test asap!
Just keep in mind that it can find only active game objects.
Any way to make this more generic? Like any string value on any component matching a given string?