Skip to content

Commit

Permalink
Tpk - UnityVersion - fix fromString
Browse files Browse the repository at this point in the history
  • Loading branch information
K0lb3 committed Nov 19, 2024
1 parent c477355 commit eece6ad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion UnityPy/helpers/Tpk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import re
from enum import IntEnum, IntFlag
from importlib.resources import open_binary
from io import BytesIO
Expand Down Expand Up @@ -300,7 +301,11 @@ def fromStream(stream: BytesIO) -> UnityVersion:

@staticmethod
def fromString(version: str) -> UnityVersion:
return UnityVersion(version.split("."))
match = re.match(r"(\d+)\.(\d+)\.(\d+)(([a-zA-Z]+)(\d+))?", version)
if not match:
raise ValueError("Invalid version string")
major, minor, patch, _, type, build = match.groups()
return UnityVersion.fromList(int(major), int(minor), int(patch), int(build))

@staticmethod
def fromList(
Expand Down

0 comments on commit eece6ad

Please sign in to comment.