diff --git a/src/main/kotlin/io/github/deficuet/unitykt/utils.kt b/src/main/kotlin/io/github/deficuet/unitykt/utils.kt index 7e145bbb..23863284 100644 --- a/src/main/kotlin/io/github/deficuet/unitykt/utils.kt +++ b/src/main/kotlin/io/github/deficuet/unitykt/utils.kt @@ -53,7 +53,9 @@ fun Collection.allObjectsOf(vararg type: String): List { } inline fun Collection.safeFindWithPathID(pathId: Long): T? { - return with(first { it.mPathID == pathId }) { if (this is T) this else null } + return find { it.mPathID == pathId }?.let { + if (it is T) it else null + } } inline fun Collection.findWithPathID(pathId: Long): T {