Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Python script to clear all the PublicizedFrom attributes from lambdas
- in its parent directory.
- Put it in Assets/Scripts/Assembly-CSharp as strip_lambda_attributes.py,
- open the folder in terminal, and run:
- python strip_lambda_attributes.py
- """
- import os
- import re
- # Regex to match `[PublicizedFrom(...)]` before a lambda parameter
- lambda_attr_regex = re.compile(
- r"""\[\s*PublicizedFrom\s*\([^)]*\)\s*\]\s*(?=\()""",
- re.MULTILINE
- )
- def process_file(filepath):
- with open(filepath, "r", encoding="utf-8") as f:
- content = f.read()
- new_content, count = lambda_attr_regex.subn('', content)
- if count > 0:
- with open(filepath, "w", encoding="utf-8") as f:
- f.write(new_content)
- print(f"✅ Fixed {count} lambda(s) in {filepath}")
- def walk_and_process(directory):
- for root, _, files in os.walk(directory):
- for name in files:
- if name.endswith(".cs"):
- process_file(os.path.join(root, name))
- if __name__ == "__main__":
- project_dir = os.getcwd() # Run the script from the Unity project root
- print(f"🔍 Scanning project: {project_dir}")
- walk_and_process(project_dir)
- print("🎉 Done! All `[PublicizedFrom(...)]` lambdas cleaned.")
Advertisement
Add Comment
Please, Sign In to add comment