You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't move game files after loading them with UnityPy.
I call a function that has env = UnityPy.load(file_path) inside it, then after that when I try to move the file to another location, I can't do that.
Here's a simplified version of the code:
The function:
def is_excluded_file(file_path):
try:
env = UnityPy.load(file_path)
except:
return False
for path,obj in env.container.items():
if condition(path):
return True
return False
for file_path in file_walker(assetbundle_path): #recursively yields every file's path in the folder
if is_excluded_file(file_path):
dir_path = os.path.dirname(file_path)
nested_path_lib = Path(os.path.join(move_folder, dir_path))
nested_path_lib.mkdir(parents=True, exist_ok=True)
shutil.move(file_path, os.path.join(move_folder, file_path))
I get an error at that last line, saying that it's being used by another process (which is UnityPy).
Is there a way to "close" this process?
Activity
isHarryh commentedon Nov 2, 2025
See #332 .
isHarryh commentedon Nov 2, 2025
For a temporary solution, you can "record" the files you want move to a txt file, then run another script to move them.
firas5673 commentedon Nov 2, 2025
Yeah, I did exactly that. My project is small, but I could see this becoming an issue in bigger projects.
K0lb3 commentedon Nov 3, 2025
UnityPy doesn't explicitly call close on opened handles.
It just drops the object, so the garbage cleaner will at some point close the file handle.
You basically have three ways to work around this.