AssetsTools icon indicating copy to clipboard operation
AssetsTools copied to clipboard

Feature request: DynamicAssetArray.Length

Open therealchjones opened this issue 4 years ago • 0 comments

For various access methods to DynamicAssetArrays, a loop is beneficial (or required); either implementing IEnumerable or a Length (or Count, or whatever) property would improve the ability to do this. As the elems array is internal, this is not cleanly doable with an extension method. For now, I'm using:

		public static int Count( this DynamicAssetArray array ) {
			int length = 0;
			dynamic foo = null;
			try {
				while ( true ) {
					foo = array[length];
					length++;
				}
			} catch ( IndexOutOfRangeException ) {
				return length;
			}
		}

However, this is quite a performance hit for the many DynamicAssetArrays present in the assets I'm examining. Would you be willing to consider this? I'm more than happy to submit a PR if it's something you'd consider.

therealchjones avatar Jun 06 '21 21:06 therealchjones