mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-01 19:13:03 +08:00
Cleanup and DontDestroy fixes
This commit is contained in:
@ -24,9 +24,9 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
Parent = parent;
|
Parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SearchContext m_context = SearchContext.UnityObject;
|
private SearchContext context = SearchContext.UnityObject;
|
||||||
private SceneFilter m_sceneFilter = SceneFilter.Any;
|
private SceneFilter sceneFilter = SceneFilter.Any;
|
||||||
private ChildFilter m_childFilter = ChildFilter.Any;
|
private ChildFilter childFilter = ChildFilter.Any;
|
||||||
private string desiredTypeInput;
|
private string desiredTypeInput;
|
||||||
private string lastCheckedTypeInput;
|
private string lastCheckedTypeInput;
|
||||||
private bool lastTypeCanHaveGO;
|
private bool lastTypeCanHaveGO;
|
||||||
@ -34,7 +34,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
public ButtonListHandler<object, ButtonCell> dataHandler;
|
public ButtonListHandler<object, ButtonCell> dataHandler;
|
||||||
|
|
||||||
private ScrollPool<ButtonCell> resultsScrollPool;
|
private ScrollPool<ButtonCell> resultsScrollPool;
|
||||||
private List<object> currentResults = new List<object>();
|
private List<object> currentResults = new();
|
||||||
|
|
||||||
public TypeCompleter typeAutocompleter;
|
public TypeCompleter typeAutocompleter;
|
||||||
|
|
||||||
@ -54,12 +54,12 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
{
|
{
|
||||||
cachedCellTexts.Clear();
|
cachedCellTexts.Clear();
|
||||||
|
|
||||||
if (m_context == SearchContext.Singleton)
|
if (context == SearchContext.Singleton)
|
||||||
currentResults = SearchProvider.SingletonSearch(nameInputField.Text);
|
currentResults = SearchProvider.SingletonSearch(nameInputField.Text);
|
||||||
else if (m_context == SearchContext.Class)
|
else if (context == SearchContext.Class)
|
||||||
currentResults = SearchProvider.ClassSearch(nameInputField.Text);
|
currentResults = SearchProvider.ClassSearch(nameInputField.Text);
|
||||||
else
|
else
|
||||||
currentResults = SearchProvider.UnityObjectSearch(nameInputField.Text, desiredTypeInput, m_context, m_childFilter, m_sceneFilter);
|
currentResults = SearchProvider.UnityObjectSearch(nameInputField.Text, desiredTypeInput, childFilter, sceneFilter);
|
||||||
|
|
||||||
dataHandler.RefreshData();
|
dataHandler.RefreshData();
|
||||||
resultsScrollPool.Refresh(true);
|
resultsScrollPool.Refresh(true);
|
||||||
@ -69,7 +69,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (m_context == SearchContext.UnityObject && lastCheckedTypeInput != desiredTypeInput)
|
if (context == SearchContext.UnityObject && lastCheckedTypeInput != desiredTypeInput)
|
||||||
{
|
{
|
||||||
lastCheckedTypeInput = desiredTypeInput;
|
lastCheckedTypeInput = desiredTypeInput;
|
||||||
|
|
||||||
@ -94,18 +94,18 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
|
|
||||||
private void OnContextDropdownChanged(int value)
|
private void OnContextDropdownChanged(int value)
|
||||||
{
|
{
|
||||||
m_context = (SearchContext)value;
|
context = (SearchContext)value;
|
||||||
|
|
||||||
lastCheckedTypeInput = null;
|
lastCheckedTypeInput = null;
|
||||||
sceneFilterRow.SetActive(false);
|
sceneFilterRow.SetActive(false);
|
||||||
childFilterRow.SetActive(false);
|
childFilterRow.SetActive(false);
|
||||||
|
|
||||||
unityObjectClassRow.SetActive(m_context == SearchContext.UnityObject);
|
unityObjectClassRow.SetActive(context == SearchContext.UnityObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSceneFilterDropChanged(int value) => m_sceneFilter = (SceneFilter)value;
|
private void OnSceneFilterDropChanged(int value) => sceneFilter = (SceneFilter)value;
|
||||||
|
|
||||||
private void OnChildFilterDropChanged(int value) => m_childFilter = (ChildFilter)value;
|
private void OnChildFilterDropChanged(int value) => childFilter = (ChildFilter)value;
|
||||||
|
|
||||||
private void OnTypeInputChanged(string val)
|
private void OnTypeInputChanged(string val)
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
if (!cachedCellTexts.ContainsKey(index))
|
if (!cachedCellTexts.ContainsKey(index))
|
||||||
{
|
{
|
||||||
string text;
|
string text;
|
||||||
if (m_context == SearchContext.Class)
|
if (context == SearchContext.Class)
|
||||||
{
|
{
|
||||||
var type = currentResults[index] as Type;
|
var type = currentResults[index] as Type;
|
||||||
text = $"{SignatureHighlighter.Parse(type, true)} <color=grey><i>({type.Assembly.GetName().Name})</i></color>";
|
text = $"{SignatureHighlighter.Parse(type, true)} <color=grey><i>({type.Assembly.GetName().Name})</i></color>";
|
||||||
@ -143,7 +143,7 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
|
|
||||||
private void OnCellClicked(int dataIndex)
|
private void OnCellClicked(int dataIndex)
|
||||||
{
|
{
|
||||||
if (m_context == SearchContext.Class)
|
if (context == SearchContext.Class)
|
||||||
InspectorManager.Inspect(currentResults[dataIndex] as Type);
|
InspectorManager.Inspect(currentResults[dataIndex] as Type);
|
||||||
else
|
else
|
||||||
InspectorManager.Inspect(currentResults[dataIndex]);
|
InspectorManager.Inspect(currentResults[dataIndex]);
|
||||||
@ -210,7 +210,11 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
|
|
||||||
var sceneDropObj = UIFactory.CreateDropdown(sceneFilterRow, out Dropdown sceneDrop, null, 14, OnSceneFilterDropChanged);
|
var sceneDropObj = UIFactory.CreateDropdown(sceneFilterRow, out Dropdown sceneDrop, null, 14, OnSceneFilterDropChanged);
|
||||||
foreach (var name in Enum.GetNames(typeof(SceneFilter)))
|
foreach (var name in Enum.GetNames(typeof(SceneFilter)))
|
||||||
|
{
|
||||||
|
if (!SceneHandler.DontDestroyExists && name == "DontDestroyOnLoad")
|
||||||
|
continue;
|
||||||
sceneDrop.options.Add(new Dropdown.OptionData(name));
|
sceneDrop.options.Add(new Dropdown.OptionData(name));
|
||||||
|
}
|
||||||
UIFactory.SetLayoutElement(sceneDropObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999);
|
UIFactory.SetLayoutElement(sceneDropObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999);
|
||||||
|
|
||||||
sceneFilterRow.SetActive(false);
|
sceneFilterRow.SetActive(false);
|
||||||
|
@ -42,18 +42,17 @@ namespace UnityExplorer.ObjectExplorer
|
|||||||
case SceneFilter.Any:
|
case SceneFilter.Any:
|
||||||
return true;
|
return true;
|
||||||
case SceneFilter.DontDestroyOnLoad:
|
case SceneFilter.DontDestroyOnLoad:
|
||||||
return scene == SceneHandler.DontDestroyScene;
|
return scene.handle == -12;
|
||||||
case SceneFilter.HideAndDontSave:
|
case SceneFilter.HideAndDontSave:
|
||||||
return scene == default;
|
return scene == default;
|
||||||
case SceneFilter.ActivelyLoaded:
|
case SceneFilter.ActivelyLoaded:
|
||||||
return scene != SceneHandler.DontDestroyScene && scene != default;
|
return scene.buildIndex != -1;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<object> UnityObjectSearch(string input, string customTypeInput, SearchContext context,
|
internal static List<object> UnityObjectSearch(string input, string customTypeInput, ChildFilter childFilter, SceneFilter sceneFilter)
|
||||||
ChildFilter childFilter, SceneFilter sceneFilter)
|
|
||||||
{
|
{
|
||||||
var results = new List<object>();
|
var results = new List<object>();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user