From 1e97e0e099c16dd6591c6d367c55d5520f1866d5 Mon Sep 17 00:00:00 2001 From: Alba Mendez Date: Mon, 2 Dec 2019 18:40:48 +0100 Subject: [PATCH 1/2] Set base_path to directory of bundle file --- unitypack/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/unitypack/__init__.py b/unitypack/__init__.py index 78ea144..d668835 100644 --- a/unitypack/__init__.py +++ b/unitypack/__init__.py @@ -1,4 +1,5 @@ import pkg_resources +from os.path import dirname __version__ = pkg_resources.require("unitypack")[0].version @@ -8,7 +9,7 @@ def load(file, env=None): from .environment import UnityEnvironment if env is None: - env = UnityEnvironment() + env = UnityEnvironment(dirname(file.name)) return env.load(file) @@ -16,5 +17,5 @@ def load_from_file(file, env=None): from .environment import UnityEnvironment if env is None: - env = UnityEnvironment() + env = UnityEnvironment(dirname(file.name)) return env.get_asset_by_filename(file) From 87f0c906ad4fe5cec29042fecc0cc31eb94d0a0d Mon Sep 17 00:00:00 2001 From: Alba Mendez Date: Mon, 2 Dec 2019 18:50:11 +0100 Subject: [PATCH 2/2] README: Note external assets --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 9409663..8d90062 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ field or TextAsset's `m_Script` field. Using this, files can be "extracted" from bundles by using their `m_Name` and an appropriate extension. But doing so leaves out all the "unextractable" classes which one might want to deal with. +**Note:** Unity3D files may sometimes reference external files. By default UnityPack will +look for these files in the same directory as the Unity3D file. + ## Usage