Skip to content

Let callers supply a Unity version for version-stripped files #105

Closed

Description

@fatal10110

Package: packages/core (npm unity-asset-reader)

Description

Since #99 (PR #107), a version-stripped SerializedFile keeps version [0, 0, 0, 0] when the bundle it belongs to does not record a revision. That covers every editor-built stripped bundle: 2019.4.41f2, 2020.3.30f1 and 6000.3.25f1 all write "0.0.0" in the bundle header too. The objects stay readable through their typetrees. But version-gated class readers refuse [0, 0, 0, 0] with UnsupportedError (the rule recorded on #28 and #36), so a caller cannot use them on such a bundle, even when they know which editor built it. This is a convenience, not a blocker.

Both upstreams let the caller supply the version:

  • AssetStudio AssetsManager: SpecifyUnityVersion (overrides every file) and DefaultVersion (used only for a stripped file with nothing detected), both read in CheckStrippedVersion.
  • UnityPy: config.FALLBACK_UNITY_VERSION, used by SerializedFile.set_version and BundleFile.parse_version when there is no usable version.

Raised while implementing #99.

Tasks

  • Design the option (for example a unityVersion fallback on load()) and decide whether it only fills a stripped version (DefaultVersion / UnityPy) or also overrides recorded ones (SpecifyUnityVersion). Record the choice in the PR.
  • Apply it in env.ts after the enclosing-bundle fallback from Fall back to a bundle revision for version-stripped SerializedFiles #99, reusing setUnityVersion.
  • Test with a hand-built version-stripped file, both loose and in a bundle with a stripped revision.

Port

AssetStudio/AssetsManager.cs (CheckStrippedVersion, SpecifyUnityVersion, DefaultVersion).

Acceptance

  • A version-stripped SerializedFile with no usable bundle revision reports the caller-supplied version when one is given, and keeps [0, 0, 0, 0] when none is.
  • Files that record their version are unaffected.

Plan: docs/unity-asset-reader-plan.md. Behavior source of truth: Razviar/assetstudio (MIT). Golden oracle: UnityPy (MIT). MIT-derivative port: keep upstream copyright notices. Do not copy or import @arkntools/unity-js (AGPL-3.0), tests included. No C# compiled to WASM - C# is reference only, hand-ported to TS; WASM is built from C/C++ only (plan D2). Layout: npm-workspaces monorepo under packages/; dependencies point feature package -> core only (plan D7/D8, rules R13/R14).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:serializedSerializedFile and TypeTreebacklogOn-demand, no named consumer yet

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions