Skip to content

Documentation update with better examples of objects reading and editing#350

Open
isHarryh wants to merge 3 commits intoK0lb3:masterfrom
isHarryh:docs
Open

Documentation update with better examples of objects reading and editing#350
isHarryh wants to merge 3 commits intoK0lb3:masterfrom
isHarryh:docs

Conversation

@isHarryh
Copy link
Contributor

@isHarryh isHarryh commented Nov 4, 2025

Summary

This PR updates the README file:

  • Adds tips for properly closing files (use with and open() to manage file handle). We already have some issues like Can't move files after opening them #349 related to the new file-locking feature introduced in 1.23.0. The best way to avoid these issues is to improve our documentation.
  • Adds details for object modification. Btw, fixes a outdated code that obj.save(instance) should be instance.save().

closes #349
closes #332

@K0lb3
Copy link
Owner

K0lb3 commented Nov 29, 2025

Thanks, I will try to come around combining your changes with the ones I recently made.

# note that the best way to pass a file to UnityPy is
# using with-statement to ensure the file can be properly closed
with open("path/to/your/file", "rb") as f:
env = UnityPy.load(f)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could actually cause issues for SerializedFiles, as they aren't read into memory due to no decompression.
Something like

f = open(fp, "rb")
env = UnityPy.load(f)
# use the environment
f.close()

would be better

@K0lb3
Copy link
Owner

K0lb3 commented Feb 19, 2026

Welp, sorry, I somehow totally forgot about your PR -.-'

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't move files after opening them File is locked

2 participants

Comments