Skip to content

Commit

Permalink
update PPtr
Browse files Browse the repository at this point in the history
  • Loading branch information
Deficuet authored and Deficuet committed Jan 8, 2024
1 parent 76631dc commit 5af65aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ internal class AssetBundleImpl(
return fmPathFlags
}

internal var dependenciesLoaded = false

override fun read() {
super.read()
fmPreloadTable = reader.readArrayOf { PPtrImpl(this) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.deficuet.unitykt.internal.impl

import io.github.deficuet.unitykt.cast
import io.github.deficuet.unitykt.classes.AssetBundle
import io.github.deficuet.unitykt.classes.UnityObject
import io.github.deficuet.unitykt.internal.file.FormatVersion
import io.github.deficuet.unitykt.internal.file.SerializedFile
Expand Down Expand Up @@ -49,17 +48,20 @@ internal class PPtrImpl<out T: UnityObject>: PPtr<T> {
if (result != null) return result
if (manager.assetRootFolder == null) return null
val bundle = assetFile.objectMap[1L] ?: return null
if (bundle !is AssetBundle) return null
for (dependencyName in bundle.mDependencies) {
try {
manager.loadFile(
manager.assetRootFolder.resolve(dependencyName),
manager.defaultReaderConfig
)
} catch (e: Exception) {
println("An error occurred during loading dependency file ${dependencyName}: ${e.message}")
continue
if (bundle !is AssetBundleImpl) return null
if (!bundle.dependenciesLoaded) {
for (dependencyName in bundle.mDependencies) {
try {
manager.loadFile(
manager.assetRootFolder.resolve(dependencyName),
manager.defaultReaderConfig
)
} catch (e: Exception) {
println("An error occurred during loading dependency file ${dependencyName}: ${e.message}")
continue
}
}
bundle.dependenciesLoaded = true
}
return manager.assetFiles[assetFile.externals[fileIndex].name.lowercase()]
}
Expand Down

0 comments on commit 5af65aa

Please sign in to comment.