mirror of
https://github.com/yasirkula/UnityAssetUsageDetector.git
synced 2026-11-19 22:42:37 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e7369e44e | |||
| 7b60eeacf7 | |||
| b8470536b9 | |||
| 1bebc8691d | |||
| 5a81e5011b | |||
| ba7539d983 |
@@ -547,26 +547,10 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder( objectsToSearchSet.Count * 50 + callStack.Count * 50 + 500 );
|
||||
StringBuilder sb = new StringBuilder( objectsToSearchSet.Count * 50 + callStack.Count * 50 + 1000 );
|
||||
sb.AppendLine( "<b>AssetUsageDetector Error:</b>" ).AppendLine().Append( e ).AppendLine();
|
||||
if( callStack.Count > 0 )
|
||||
{
|
||||
sb.AppendLine( "Stack contents: " );
|
||||
for( int i = callStack.Count - 1; i >= 0; i-- )
|
||||
{
|
||||
sb.Append( i ).Append( ": " );
|
||||
|
||||
Object unityObject = callStack[i] as Object;
|
||||
if( unityObject )
|
||||
sb.Append( unityObject.name ).Append( " (" ).Append( unityObject.GetType() ).AppendLine( ")" );
|
||||
else if( callStack[i] != null )
|
||||
sb.Append( callStack[i].GetType() ).AppendLine( " object" );
|
||||
else
|
||||
sb.AppendLine( "<<destroyed>>" );
|
||||
}
|
||||
|
||||
sb.AppendLine();
|
||||
}
|
||||
Object latestUnityObjectInCallStack = AppendCallStackToStringBuilder( sb );
|
||||
|
||||
sb.AppendLine( "Searching references of: " );
|
||||
foreach( Object obj in objectsToSearchSet )
|
||||
@@ -575,7 +559,7 @@ namespace AssetUsageDetectorNamespace
|
||||
sb.Append( obj.name ).Append( " (" ).Append( obj.GetType() ).AppendLine( ")" );
|
||||
}
|
||||
|
||||
Debug.LogError( sb.ToString() );
|
||||
Debug.LogError( sb.ToString(), latestUnityObjectInCallStack );
|
||||
|
||||
try
|
||||
{
|
||||
@@ -616,7 +600,9 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
if( shouldOpenPrefabStageWithoutContext )
|
||||
#endif
|
||||
AssetDatabase.OpenAsset( AssetDatabase.LoadAssetAtPath<GameObject>( openPrefabStageAssetPath ) );
|
||||
{
|
||||
AssetDatabase.OpenAsset( AssetDatabase.LoadAssetAtPath<GameObject>( openPrefabStageAssetPath ) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1087,5 +1073,48 @@ namespace AssetUsageDetectorNamespace
|
||||
Object.DestroyImmediate( temp );
|
||||
}
|
||||
}
|
||||
|
||||
// Appends contents of callStack to StringBuilder and returns the most recent Unity object in callStack
|
||||
private Object AppendCallStackToStringBuilder( StringBuilder sb )
|
||||
{
|
||||
Object latestUnityObjectInCallStack = null;
|
||||
if( callStack.Count > 0 )
|
||||
{
|
||||
sb.AppendLine().AppendLine( "Stack contents: " );
|
||||
|
||||
for( int i = callStack.Count - 1; i >= 0; i-- )
|
||||
{
|
||||
latestUnityObjectInCallStack = callStack[i] as Object;
|
||||
if( latestUnityObjectInCallStack )
|
||||
{
|
||||
if( !AssetDatabase.Contains( latestUnityObjectInCallStack ) )
|
||||
{
|
||||
string scenePath = AssetDatabase.GetAssetOrScenePath( latestUnityObjectInCallStack );
|
||||
if( !string.IsNullOrEmpty( scenePath ) && SceneManager.GetSceneByPath( scenePath ).IsValid() )
|
||||
sb.Append( "Scene: " ).AppendLine( scenePath );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for( int i = callStack.Count - 1; i >= 0; i-- )
|
||||
{
|
||||
sb.Append( i ).Append( ": " );
|
||||
|
||||
Object unityObject = callStack[i] as Object;
|
||||
if( unityObject )
|
||||
sb.Append( unityObject.name ).Append( " (" ).Append( unityObject.GetType() ).AppendLine( ")" );
|
||||
else if( callStack[i] != null )
|
||||
sb.Append( callStack[i].GetType() ).AppendLine( " object" );
|
||||
else
|
||||
sb.AppendLine( "<<destroyed>>" );
|
||||
}
|
||||
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
return latestUnityObjectInCallStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine;
|
||||
@@ -388,7 +389,29 @@ namespace AssetUsageDetectorNamespace
|
||||
Mesh[] meshes = new Mesh[( (ParticleSystemRenderer) component ).meshCount];
|
||||
int meshCount = ( (ParticleSystemRenderer) component ).GetMeshes( meshes );
|
||||
for( int i = 0; i < meshCount; i++ )
|
||||
referenceNode.AddLinkTo( SearchObject( meshes[i] ), "Custom particle mesh" );
|
||||
referenceNode.AddLinkTo( SearchObject( meshes[i] ), "Renderer Module: Mesh" );
|
||||
}
|
||||
else if( component is ParticleSystem )
|
||||
{
|
||||
// Some ParticleSystem properties aren't searched by SerializedObject, search them manually instead
|
||||
ParticleSystem particleSystem = (ParticleSystem) component;
|
||||
referenceNode.AddLinkTo( SearchObject( particleSystem.lights.light ), "Light Module: Light" );
|
||||
|
||||
try
|
||||
{
|
||||
ParticleSystem.CollisionModule collisionModule = particleSystem.collision;
|
||||
for( int i = 0, j = collisionModule.maxPlaneCount; i < j; i++ )
|
||||
referenceNode.AddLinkTo( SearchObject( collisionModule.GetPlane( i ) ), "Collision Module: Plane" );
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
ParticleSystem.TriggerModule triggerModule = particleSystem.trigger;
|
||||
for( int i = 0, j = triggerModule.maxColliderCount; i < j; i++ )
|
||||
referenceNode.AddLinkTo( SearchObject( triggerModule.GetCollider( i ) ), "Trigger Module: Collider" );
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
else if( searchRenderers && component is Renderer )
|
||||
{
|
||||
@@ -569,6 +592,13 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
else
|
||||
{
|
||||
if( controller is AnimatorOverrideController )
|
||||
{
|
||||
RuntimeAnimatorController parentController = ( (AnimatorOverrideController) controller ).runtimeAnimatorController;
|
||||
if( objectsToSearchSet.Contains( parentController ) )
|
||||
referenceNode.AddLinkTo( GetReferenceNode( parentController ) );
|
||||
}
|
||||
|
||||
AnimationClip[] animClips = controller.animationClips;
|
||||
for( int i = 0; i < animClips.Length; i++ )
|
||||
referenceNode.AddLinkTo( SearchObject( animClips[i] ) );
|
||||
@@ -991,26 +1021,38 @@ namespace AssetUsageDetectorNamespace
|
||||
SerializedProperty iteratorVisible = so.GetIterator();
|
||||
if( iterator.Next( true ) )
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath( (Object) referenceNode.nodeObject );
|
||||
bool isProjectSettings = !string.IsNullOrEmpty( assetPath ) && assetPath.StartsWithFast( "ProjectSettings/" );
|
||||
|
||||
bool iteratingVisible = iteratorVisible.NextVisible( true );
|
||||
bool enterChildren;
|
||||
do
|
||||
{
|
||||
// Iterate over NextVisible properties AND the properties that have corresponding FieldInfos (internal Unity
|
||||
// properties don't have FieldInfos so we are skipping them, which is good because search results found in
|
||||
// those properties aren't interesting and mostly confusing)
|
||||
bool isVisible = iteratingVisible && SerializedProperty.EqualContents( iterator, iteratorVisible );
|
||||
if( isVisible )
|
||||
iteratingVisible = iteratorVisible.NextVisible( true );
|
||||
if( isProjectSettings )
|
||||
{
|
||||
// Search Project Settings in full because for some reason, important settings like SRP asset
|
||||
// slot in Quality Settings aren't searched when iterating over only visible properties
|
||||
enterChildren = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Type propFieldType;
|
||||
isVisible = iterator.type == "Array" || fieldInfoGetter( iterator, out propFieldType ) != null;
|
||||
}
|
||||
// Iterate over NextVisible properties AND the properties that have corresponding FieldInfos (internal Unity
|
||||
// properties don't have FieldInfos so we are skipping them, which is good because search results found in
|
||||
// those properties aren't interesting and mostly confusing)
|
||||
bool isVisible = iteratingVisible && SerializedProperty.EqualContents( iterator, iteratorVisible );
|
||||
if( isVisible )
|
||||
iteratingVisible = iteratorVisible.NextVisible( true );
|
||||
else
|
||||
{
|
||||
Type propFieldType;
|
||||
isVisible = iterator.type == "Array" || fieldInfoGetter( iterator, out propFieldType ) != null;
|
||||
}
|
||||
|
||||
if( !isVisible )
|
||||
{
|
||||
enterChildren = false;
|
||||
continue;
|
||||
if( !isVisible )
|
||||
{
|
||||
enterChildren = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ReferenceNode searchResult;
|
||||
@@ -1072,7 +1114,7 @@ namespace AssetUsageDetectorNamespace
|
||||
try
|
||||
{
|
||||
object variableValue = variables[i].Get( referenceNode.nodeObject );
|
||||
if( variableValue == null )
|
||||
if( variableValue == null || variableValue.Equals( null ) )
|
||||
continue;
|
||||
|
||||
// Values stored inside ICollection objects are searched using IEnumerable,
|
||||
@@ -1103,6 +1145,15 @@ namespace AssetUsageDetectorNamespace
|
||||
catch( MissingReferenceException ) { }
|
||||
catch( MissingComponentException ) { }
|
||||
catch( NotImplementedException ) { }
|
||||
catch( Exception e )
|
||||
{
|
||||
// Unknown exceptions usually occur when variableValue is an IEnumerable and its enumerator throws an unhandled exception in MoveNext or Current
|
||||
StringBuilder sb = new StringBuilder( callStack.Count * 50 + 1000 );
|
||||
sb.Append( "Skipped searching " ).Append( referenceNode.nodeObject.GetType().FullName ).Append( "." ).Append( variables[i].name ).AppendLine( " because it threw exception:" ).Append( e ).AppendLine();
|
||||
|
||||
Object latestUnityObjectInCallStack = AppendCallStackToStringBuilder( sb );
|
||||
Debug.LogWarning( sb.ToString(), latestUnityObjectInCallStack );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1189,22 +1240,20 @@ namespace AssetUsageDetectorNamespace
|
||||
if( propertyGetter.GetBaseDefinition().DeclaringType != propertyGetter.DeclaringType )
|
||||
continue;
|
||||
|
||||
// Additional filtering for properties:
|
||||
// 1- Ignore "gameObject", "transform", "rectTransform" and "attachedRigidbody" properties of Component's to get more useful results
|
||||
// 2- Ignore "canvasRenderer" and "canvas" properties of Graphic components
|
||||
// 3 & 4- Prevent accessing properties of Unity that instantiate an existing resource (causing memory leak)
|
||||
string propertyName = property.Name;
|
||||
|
||||
// Ignore "gameObject", "transform", "rectTransform" and "attachedRigidbody" properties of components to get more useful results
|
||||
if( typeof( Component ).IsAssignableFrom( currType ) && ( propertyName == "gameObject" ||
|
||||
propertyName == "transform" || propertyName == "attachedRigidbody" || propertyName == "rectTransform" ) )
|
||||
continue;
|
||||
// Ignore "canvasRenderer" and "canvas" properties of Graphic components to get more useful results
|
||||
else if( typeof( Graphic ).IsAssignableFrom( currType ) &&
|
||||
( propertyName == "canvasRenderer" || propertyName == "canvas" ) )
|
||||
continue;
|
||||
// Prevent accessing properties of Unity that instantiate an existing resource (causing memory leak)
|
||||
else if( typeof( MeshFilter ).IsAssignableFrom( currType ) && propertyName == "mesh" )
|
||||
continue;
|
||||
else if( typeof( Renderer ).IsAssignableFrom( currType ) &&
|
||||
( propertyName == "sharedMaterial" || propertyName == "sharedMaterials" ) )
|
||||
continue;
|
||||
// Same as above
|
||||
else if( ( propertyName == "material" || propertyName == "materials" ) &&
|
||||
( typeof( Renderer ).IsAssignableFrom( currType ) || typeof( Collider ).IsAssignableFrom( currType ) ||
|
||||
#if !UNITY_2019_3_OR_NEWER
|
||||
@@ -1214,6 +1263,19 @@ namespace AssetUsageDetectorNamespace
|
||||
#endif
|
||||
typeof( Collider2D ).IsAssignableFrom( currType ) ) )
|
||||
continue;
|
||||
// "sharedMaterials" are searched via SearchComponent, no need to search it with reflection, as well
|
||||
else if( typeof( Renderer ).IsAssignableFrom( currType ) &&
|
||||
( propertyName == "sharedMaterial" || propertyName == "sharedMaterials" ) )
|
||||
continue;
|
||||
// Ignore "parameters" property of Animator since it doesn't contain any useful data and logs a warning to the console when Animator is inactive
|
||||
else if( typeof( Animator ).IsAssignableFrom( currType ) && propertyName == "parameters" )
|
||||
continue;
|
||||
// Ignore "spriteAnimator" property of TMP_Text component because this property adds a TMP_SpriteAnimator component to the object if it doesn't exist
|
||||
else if( propertyName == "spriteAnimator" && currType.Name == "TMP_Text" )
|
||||
continue;
|
||||
// Ignore "meshFilter" property of TextMeshPro and TMP_SubMesh components because this property adds a MeshFilter component to the object if it doesn't exist
|
||||
else if( propertyName == "meshFilter" && ( currType.Name == "TextMeshPro" || currType.Name == "TMP_SubMesh" ) )
|
||||
continue;
|
||||
else
|
||||
{
|
||||
VariableGetVal getter = property.CreateGetter();
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
private static void ShowAndSearchInternal( IEnumerable<Object> searchObjects, AssetUsageDetector.Parameters searchParameters, bool? shouldSearchChildren )
|
||||
{
|
||||
if( mainWindow != null && !mainWindow.ReturnToSetupPhase( true ) )
|
||||
if( mainWindow != null && !mainWindow.ReturnToSetupPhase( true, true ) )
|
||||
{
|
||||
Debug.LogError( "Need to reset the previous search first!" );
|
||||
return;
|
||||
@@ -280,11 +280,8 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
SavePrefs();
|
||||
|
||||
if( searchResult != null && currentPhase == Phase.Complete && !EditorApplication.isPlaying && searchResult.IsSceneSetupDifferentThanCurrentSetup() )
|
||||
{
|
||||
if( EditorUtility.DisplayDialog( "Scenes", "Restore initial scene setup?", "Yes", "Leave it as is" ) )
|
||||
searchResult.RestoreInitialSceneSetup();
|
||||
}
|
||||
if( searchResult != null && currentPhase == Phase.Complete )
|
||||
searchResult.RestoreInitialSceneSetup( true );
|
||||
}
|
||||
|
||||
private void OnFocus()
|
||||
@@ -399,7 +396,7 @@ namespace AssetUsageDetectorNamespace
|
||||
restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup );
|
||||
|
||||
if( GUILayout.Button( "RETURN", Utilities.GL_HEIGHT_30 ) )
|
||||
ReturnToSetupPhase( restoreInitialSceneSetup );
|
||||
ReturnToSetupPhase( restoreInitialSceneSetup, false );
|
||||
}
|
||||
else if( currentPhase == Phase.Setup )
|
||||
{
|
||||
@@ -408,12 +405,10 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
GUILayout.Space( 10 );
|
||||
|
||||
Color c = GUI.color;
|
||||
GUI.color = Color.cyan;
|
||||
|
||||
Color c = GUI.backgroundColor;
|
||||
GUI.backgroundColor = Color.cyan;
|
||||
GUILayout.Box( "SEARCH IN", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
|
||||
|
||||
GUI.color = c;
|
||||
GUI.backgroundColor = c;
|
||||
|
||||
searchInAssetsFolder = EditorGUILayout.ToggleLeft( "Project window (Assets folder)", searchInAssetsFolder );
|
||||
|
||||
@@ -526,11 +521,9 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
//GUILayout.Space( 10 );
|
||||
|
||||
GUI.color = Color.cyan;
|
||||
|
||||
GUI.backgroundColor = Color.cyan;
|
||||
GUILayout.Box( "SETTINGS", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
|
||||
|
||||
GUI.color = c;
|
||||
GUI.backgroundColor = c;
|
||||
|
||||
lazySceneSearch = EditorGUILayout.ToggleLeft( "Lazy scene search: scenes are searched in detail only when they are manually refreshed (faster search)", lazySceneSearch );
|
||||
noAssetDatabaseChanges = EditorGUILayout.ToggleLeft( "I haven't modified any assets/scenes since the last search (faster search)", noAssetDatabaseChanges );
|
||||
@@ -561,7 +554,7 @@ namespace AssetUsageDetectorNamespace
|
||||
restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup );
|
||||
|
||||
if( GUILayout.Button( "Reset Search", Utilities.GL_HEIGHT_30 ) )
|
||||
ReturnToSetupPhase( restoreInitialSceneSetup );
|
||||
ReturnToSetupPhase( restoreInitialSceneSetup, false );
|
||||
|
||||
if( searchResult == null )
|
||||
{
|
||||
@@ -571,10 +564,10 @@ namespace AssetUsageDetectorNamespace
|
||||
else if( !searchResult.SearchCompletedSuccessfully )
|
||||
EditorGUILayout.HelpBox( "ERROR: search was interrupted, check the logs for more info", MessageType.Error );
|
||||
|
||||
Color c = GUI.color;
|
||||
GUI.color = Color.green;
|
||||
Color c = GUI.backgroundColor;
|
||||
GUI.backgroundColor = Color.green;
|
||||
GUILayout.Box( "Don't forget to save scene(s) if you made any changes!", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
|
||||
GUI.color = c;
|
||||
GUI.backgroundColor = c;
|
||||
|
||||
if( searchResult.NumberOfGroups == 0 )
|
||||
{
|
||||
@@ -736,9 +729,9 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
#endif
|
||||
|
||||
private bool ReturnToSetupPhase( bool restoreInitialSceneSetup )
|
||||
private bool ReturnToSetupPhase( bool restoreInitialSceneSetup, bool sceneSetupRestorationIsOptional )
|
||||
{
|
||||
if( searchResult != null && restoreInitialSceneSetup && !EditorApplication.isPlaying && !searchResult.RestoreInitialSceneSetup() )
|
||||
if( searchResult != null && restoreInitialSceneSetup && !EditorApplication.isPlaying && !searchResult.RestoreInitialSceneSetup( sceneSetupRestorationIsOptional ) )
|
||||
return false;
|
||||
|
||||
searchResult = null;
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
// Close the scenes that were not part of the initial scene setup
|
||||
// Returns true if initial scene setup is restored successfully
|
||||
public bool RestoreInitialSceneSetup()
|
||||
public bool RestoreInitialSceneSetup( bool optional )
|
||||
{
|
||||
if( initialSceneSetup == null || initialSceneSetup.Length == 0 )
|
||||
return true;
|
||||
@@ -336,6 +336,9 @@ namespace AssetUsageDetectorNamespace
|
||||
if( EditorApplication.isPlaying || !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo() )
|
||||
return false;
|
||||
|
||||
if( optional && IsSceneSetupDifferentThanCurrentSetup() && !EditorUtility.DisplayDialog( "Scenes", "Restore initial scene setup?", "Yes", "Leave it as is" ) )
|
||||
return true;
|
||||
|
||||
for( int i = 0; i < initialSceneSetup.Length; i++ )
|
||||
{
|
||||
Scene scene = EditorSceneManager.GetSceneByPath( initialSceneSetup[i].path );
|
||||
@@ -679,8 +682,8 @@ namespace AssetUsageDetectorNamespace
|
||||
parameters.shouldRefreshEditorWindow = true; // A repaint is needed to work nicely with GUILayout
|
||||
}
|
||||
|
||||
Color c = GUI.color;
|
||||
GUI.color = Color.cyan;
|
||||
Color c = GUI.backgroundColor;
|
||||
GUI.backgroundColor = Color.cyan;
|
||||
|
||||
Rect rect = parameters.guiRect;
|
||||
float width = rect.width;
|
||||
@@ -739,7 +742,8 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
if( IsExpanded )
|
||||
{
|
||||
GUI.color = Color.yellow;
|
||||
// On light skin, yellow background looks better than light grey background
|
||||
GUI.backgroundColor = EditorGUIUtility.isProSkin ? c : Color.yellow;
|
||||
|
||||
if( PendingSearch )
|
||||
{
|
||||
@@ -764,7 +768,7 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
|
||||
parameters.guiRect = rect;
|
||||
GUI.color = c;
|
||||
GUI.backgroundColor = c;
|
||||
}
|
||||
|
||||
private void GenerateGUINodes( SearchResultDrawParameters parameters )
|
||||
|
||||
@@ -81,6 +81,14 @@ namespace AssetUsageDetectorNamespace
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
font = EditorStyles.label.font
|
||||
};
|
||||
|
||||
Color textColor = GUI.skin.button.normal.textColor;
|
||||
m_boxGUIStyle.normal.textColor = textColor;
|
||||
m_boxGUIStyle.hover.textColor = textColor;
|
||||
m_boxGUIStyle.focused.textColor = textColor;
|
||||
m_boxGUIStyle.active.textColor = textColor;
|
||||
|
||||
m_boxGUIStyle.fontSize = ( m_boxGUIStyle.fontSize + GUI.skin.button.fontSize ) / 2;
|
||||
}
|
||||
|
||||
return m_boxGUIStyle;
|
||||
@@ -446,7 +454,20 @@ namespace AssetUsageDetectorNamespace
|
||||
{
|
||||
// Can't use PropertyWrapper (which uses CreateDelegate) for property getters of structs
|
||||
if( propertyInfo.DeclaringType.IsValueType )
|
||||
return propertyInfo.CanRead ? ( ( obj ) => propertyInfo.GetValue( obj, null ) ) : (VariableGetVal) null;
|
||||
{
|
||||
return !propertyInfo.CanRead ? (VariableGetVal) null : ( obj ) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return propertyInfo.GetValue( obj, null );
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Property getters may return various kinds of exceptions if their backing fields are not initialized (yet)
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Type GenType = typeof( PropertyWrapper<,> ).MakeGenericType( propertyInfo.DeclaringType, propertyInfo.PropertyType );
|
||||
return ( (IPropertyAccessor) Activator.CreateInstance( GenType, propertyInfo.GetGetMethod( true ) ) ).GetValue;
|
||||
|
||||
@@ -69,8 +69,7 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Property getters may return various kinds of exceptions
|
||||
// if their backing fields are not initialized (yet)
|
||||
// Property getters may return various kinds of exceptions if their backing fields are not initialized (yet)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"name": "com.yasirkula.assetusagedetector",
|
||||
"displayName": "Asset Usage Detector",
|
||||
"version": "1.8.8",
|
||||
"version": "1.9.3",
|
||||
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
|
||||
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
|
||||
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",
|
||||
"description": "This editor extension helps you figure out at which places an asset or GameObject is used, i.e. lists the objects that refer to the asset. It is possible to search for references in the Assets folder (Project view) and/or in the scene(s) of your project. You can also search for references while in Play mode!"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user