Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set base_path to directory of bundle file #90

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions unitypack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pkg_resources
from os.path import dirname


__version__ = pkg_resources.require("unitypack")[0].version
Expand All @@ -8,13 +9,13 @@ def load(file, env=None):
from .environment import UnityEnvironment

if env is None:
env = UnityEnvironment()
env = UnityEnvironment(dirname(file.name))
return env.load(file)


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)