Skip to content

Commit 05da7ce

Browse files
committed
add configurable fallback version for SerializedFIles
1 parent 0fee975 commit 05da7ce

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎UnityPy/config.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# used when no version is defined by the SerializedFile or its BundleFile
2+
FALLBACK_UNITY_VERSION = "2.5.0f5"

‎UnityPy/files/SerializedFile.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from ..streams import EndianBinaryReader, EndianBinaryWriter
88
from ..helpers.TypeTreeHelper import TypeTreeNode
99

10+
from .. import config
11+
# only print the version warning once
12+
VERSION_WARNED = False
13+
1014
RECURSION_LIMIT = sys.getrecursionlimit()
1115

1216

@@ -290,6 +294,12 @@ def set_version(self, string_version):
290294
# weird case, but apparently can happen?
291295
# check "cant read Texture2D by 2020.3.13 f1 AssetBundle #77" for details
292296
string_version = self.parent.version_engine
297+
if string_version == "0.0.0":
298+
global VERSION_WARNED
299+
if not VERSION_WARNED:
300+
print(f"Warning: 0.0.0 version found, defaulting to UnityPy.config.FALLBACK_UNITY_VERSION\n{config.FALLBACK_UNITY_VERSION}")
301+
VERSION_WARNED = True
302+
string_version = config.FALLBACK_UNITY_VERSION
293303
build_type = re.findall(r"([^\d.])", string_version)
294304
self.build_type = BuildType(build_type[0] if build_type else "")
295305
version_split = re.split(r"\D", string_version)

0 commit comments

Comments
 (0)