Skip to content

File is locked #332

Open
Open

Description

@senoo123

After updating from version 1.22.5 to 1.23.0, using UnityPy.load(file_path) causes the .unity3d file to be locked.

Activity

  1. isHarryh commented on Jul 21, 2025

    @isHarryh
    Contributor

    Commit 0347da9 in 1.23.0 causes this problem.

    A simple test script:

    import UnityPy, os
    
    file_path = "path-to-your-file"
    
    UnityPy.load(file_path)
    
    try:
        os.rename(file_path, file_path + ".renamed")
        os.rename(file_path + ".renamed", file_path)
    except PermissionError:
        print("Occupied")
    else:
        print("Okay")
  2. K0lb3 commented on Sep 5, 2025

    @K0lb3
    Owner

    Generally, one should not directly overwrite the file one is working with, one way or another.
    UnityPy tries to keep them as filestreams to reduce the ram usage, so as long as the opened stream isn't cleared by the garbage cleaner, the file stays actively used.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions