mirror of
https://github.com/yasirkula/UnityAssetUsageDetector.git
synced 2026-11-19 14:32:37 +08:00
When an asset in "Find references of:" list is right clicked, Refresh button appears which refreshes that asset's sub-assets list
This commit is contained in:
@@ -86,12 +86,18 @@ namespace AssetUsageDetectorNamespace
|
||||
Object prevObject = GetObjectFromElement( element );
|
||||
Object newObject = EditorGUILayout.ObjectField( "", prevObject, typeof( Object ), acceptSceneObjects );
|
||||
|
||||
if( GUI.changed && prevObject != newObject )
|
||||
if( GUI.changed )
|
||||
{
|
||||
hasChanged = true;
|
||||
SetObjectOfElement( list, i, newObject );
|
||||
}
|
||||
|
||||
if( guiEnabled && newObject && ev.type == EventType.ContextClick && GUILayoutUtility.GetLastRect().Contains( ev.mousePosition ) )
|
||||
{
|
||||
OnElementRightClicked( list, i, newObject );
|
||||
ev.Use();
|
||||
}
|
||||
|
||||
if( guiEnabled )
|
||||
{
|
||||
if( GUILayout.Button( "+", Utilities.GL_WIDTH_25 ) )
|
||||
@@ -121,6 +127,7 @@ namespace AssetUsageDetectorNamespace
|
||||
protected abstract T CreateElement( Object source );
|
||||
protected abstract Object GetObjectFromElement( T element );
|
||||
protected abstract void SetObjectOfElement( List<T> list, int index, Object value );
|
||||
protected abstract void OnElementRightClicked( List<T> list, int index, Object value );
|
||||
protected abstract bool IsElementNull( T element );
|
||||
protected abstract void PostElementDrawer( T element );
|
||||
}
|
||||
@@ -146,6 +153,10 @@ namespace AssetUsageDetectorNamespace
|
||||
list[index] = value;
|
||||
}
|
||||
|
||||
protected override void OnElementRightClicked( List<Object> list, int index, Object value )
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool IsElementNull( Object element )
|
||||
{
|
||||
return element == null || element.Equals( null );
|
||||
@@ -178,6 +189,13 @@ namespace AssetUsageDetectorNamespace
|
||||
list[index].RefreshSubAssets();
|
||||
}
|
||||
|
||||
protected override void OnElementRightClicked( List<ObjectToSearch> list, int index, Object value )
|
||||
{
|
||||
GenericMenu contextMenu = new GenericMenu();
|
||||
contextMenu.AddItem( new GUIContent( "Refresh" ), false, () => SetObjectOfElement( list, index, value ) );
|
||||
contextMenu.ShowAsContext();
|
||||
}
|
||||
|
||||
protected override bool IsElementNull( ObjectToSearch element )
|
||||
{
|
||||
return element == null || element.obj == null || element.obj.Equals( null );
|
||||
|
||||
Reference in New Issue
Block a user