Skip to content

Commit

Permalink
Fixes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
yasirkula committed Sep 28, 2019
1 parent b4b3e7d commit 3719ce7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
20 changes: 16 additions & 4 deletions Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ public void Refresh( string path )
private int searchedObjectsCount; // Number of searched objects
private double searchStartTime;

private List<ReferenceNode> nodesPool = new List<ReferenceNode>( 32 );
private List<VariableGetterHolder> validVariables = new List<VariableGetterHolder>( 32 );
private readonly List<ReferenceNode> nodesPool = new List<ReferenceNode>( 32 );
private readonly List<VariableGetterHolder> validVariables = new List<VariableGetterHolder>( 32 );

private readonly string reflectionNameSpace = typeof( Assembly ).Namespace;

private string CachePath { get { return Application.dataPath + "/../Library/AssetUsageDetector.cache"; } } // Path of the cache file

Expand Down Expand Up @@ -1152,7 +1154,12 @@ private VariableGetterHolder[] GetFilteredVariablesForType( Type type )
continue;

// Skip primitive types
if( fields[i].FieldType.IsPrimitiveUnityType() )
Type variableType = fields[i].FieldType;
if( variableType.IsPrimitiveUnityType() )
continue;

// Searching assembly variables for reference throws InvalidCastException on .NET 4.0 runtime
if( typeof( Type ).IsAssignableFrom( variableType ) || variableType.Namespace == reflectionNameSpace )
continue;

// Additional filtering for fields:
Expand Down Expand Up @@ -1184,7 +1191,12 @@ private VariableGetterHolder[] GetFilteredVariablesForType( Type type )
continue;

// Skip primitive types
if( properties[i].PropertyType.IsPrimitiveUnityType() )
Type variableType = properties[i].PropertyType;
if( variableType.IsPrimitiveUnityType() )
continue;

// Searching assembly variables for reference throws InvalidCastException on .NET 4.0 runtime
if( typeof( Type ).IsAssignableFrom( variableType ) || variableType.Namespace == reflectionNameSpace )
continue;

// No need to check properties with 'override' keyword
Expand Down
5 changes: 2 additions & 3 deletions Plugins/AssetUsageDetector/Editor/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@ public static class Utilities
typeof( string ), typeof( Vector4 ), typeof( Vector3 ), typeof( Vector2 ), typeof( Rect ),
typeof( Quaternion ), typeof( Color ), typeof( Color32 ), typeof( LayerMask ),
typeof( Matrix4x4 ), typeof( AnimationCurve ), typeof( Gradient ), typeof( RectOffset ),
typeof( Assembly ), // Searching assembly variables for reference throws InvalidCastException on .NET 4.0 runtime
typeof( bool[] ), typeof( byte[] ), typeof( sbyte[] ), typeof( char[] ), typeof( decimal[] ),
typeof( double[] ), typeof( float[] ), typeof( int[] ), typeof( uint[] ), typeof( long[] ),
typeof( ulong[] ), typeof( short[] ), typeof( ushort[] ), typeof( string[] ),
typeof( Vector4[] ), typeof( Vector3[] ), typeof( Vector2[] ), typeof( Rect[] ),
typeof( Quaternion[] ), typeof( Color[] ), typeof( Color32[] ), typeof( LayerMask[] ),
typeof( Matrix4x4[] ), typeof( AnimationCurve[] ), typeof( Gradient[] ), typeof( RectOffset[] ), typeof( Assembly[] ),
typeof( Matrix4x4[] ), typeof( AnimationCurve[] ), typeof( Gradient[] ), typeof( RectOffset[] ),
typeof( List<bool> ), typeof( List<byte> ), typeof( List<sbyte> ), typeof( List<char> ), typeof( List<decimal> ),
typeof( List<double> ), typeof( List<float> ), typeof( List<int> ), typeof( List<uint> ), typeof( List<long> ),
typeof( List<ulong> ), typeof( List<short> ), typeof( List<ushort> ), typeof( List<string> ),
typeof( List<Vector4> ), typeof( List<Vector3> ), typeof( List<Vector2> ), typeof( List<Rect> ),
typeof( List<Quaternion> ), typeof( List<Color> ), typeof( List<Color32> ), typeof( List<LayerMask> ),
typeof( List<Matrix4x4> ), typeof( List<AnimationCurve> ), typeof( List<Gradient> ), typeof( List<RectOffset> ), typeof( List<Assembly> )
typeof( List<Matrix4x4> ), typeof( List<AnimationCurve> ), typeof( List<Gradient> ), typeof( List<RectOffset> )
};

private static readonly HashSet<string> folderContentsSet = new HashSet<string>();
Expand Down

0 comments on commit 3719ce7

Please sign in to comment.