Remove redundant GameObject search context

This commit is contained in:
Sinai 2021-05-11 02:39:01 +10:00
parent 4019af5936
commit 8a15c11289
2 changed files with 8 additions and 8 deletions

View File

@ -101,7 +101,7 @@ namespace UnityExplorer.UI.ObjectExplorer
{ {
m_context = (SearchContext)value; m_context = (SearchContext)value;
bool shouldShowGoFilters = m_context == SearchContext.GameObject || m_context == SearchContext.UnityObject; bool shouldShowGoFilters = m_context == SearchContext.UnityObject;
sceneFilterRow.SetActive(shouldShowGoFilters); sceneFilterRow.SetActive(shouldShowGoFilters);
childFilterRow.SetActive(shouldShowGoFilters); childFilterRow.SetActive(shouldShowGoFilters);
@ -177,7 +177,7 @@ namespace UnityExplorer.UI.ObjectExplorer
unityObjectClassRow = UIFactory.CreateHorizontalGroup(uiRoot, "UnityClassRow", false, true, true, true, 2, new Vector4(2, 2, 2, 2)); unityObjectClassRow = UIFactory.CreateHorizontalGroup(uiRoot, "UnityClassRow", false, true, true, true, 2, new Vector4(2, 2, 2, 2));
UIFactory.SetLayoutElement(unityObjectClassRow, minHeight: 25, flexibleHeight: 0); UIFactory.SetLayoutElement(unityObjectClassRow, minHeight: 25, flexibleHeight: 0);
var unityClassLbl = UIFactory.CreateLabel(unityObjectClassRow, "UnityClassLabel", "Custom Type:", TextAnchor.MiddleLeft); var unityClassLbl = UIFactory.CreateLabel(unityObjectClassRow, "UnityClassLabel", "Class filter:", TextAnchor.MiddleLeft);
UIFactory.SetLayoutElement(unityClassLbl.gameObject, minWidth: 110, flexibleWidth: 0); UIFactory.SetLayoutElement(unityClassLbl.gameObject, minWidth: 110, flexibleWidth: 0);
var classInputField = UIFactory.CreateInputField(unityObjectClassRow, "ClassInput", "..."); var classInputField = UIFactory.CreateInputField(unityObjectClassRow, "ClassInput", "...");

View File

@ -13,7 +13,7 @@ namespace UnityExplorer.UI.ObjectExplorer
public enum SearchContext public enum SearchContext
{ {
UnityObject, UnityObject,
GameObject, // GameObject,
Singleton, Singleton,
StaticClass StaticClass
} }
@ -61,9 +61,9 @@ namespace UnityExplorer.UI.ObjectExplorer
Type searchType; Type searchType;
switch (context) switch (context)
{ {
case SearchContext.GameObject: //case SearchContext.GameObject:
searchType = typeof(GameObject); // searchType = typeof(GameObject);
break; // break;
case SearchContext.UnityObject: case SearchContext.UnityObject:
default: default:
@ -100,7 +100,7 @@ namespace UnityExplorer.UI.ObjectExplorer
if (!string.IsNullOrEmpty(input)) if (!string.IsNullOrEmpty(input))
nameFilter = input; nameFilter = input;
bool canGetGameObject = context == SearchContext.GameObject || typeof(Component).IsAssignableFrom(searchType); bool canGetGameObject = searchType == typeof(GameObject) || typeof(Component).IsAssignableFrom(searchType);
foreach (var obj in allObjects) foreach (var obj in allObjects)
{ {
@ -110,7 +110,7 @@ namespace UnityExplorer.UI.ObjectExplorer
if (canGetGameObject) if (canGetGameObject)
{ {
var go = context == SearchContext.GameObject var go = searchType == typeof(GameObject)
? obj.TryCast<GameObject>() ? obj.TryCast<GameObject>()
: obj.TryCast<Component>().gameObject; : obj.TryCast<Component>().gameObject;