Skip to content

Instantly share code, notes, and snippets.

@robertwahler
Created September 10, 2019 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertwahler/d5f63f89912b20a3882b85fce4541ac0 to your computer and use it in GitHub Desktop.
Save robertwahler/d5f63f89912b20a3882b85fce4541ac0 to your computer and use it in GitHub Desktop.
Find and Replace in Unity Assets using GNU Tools

Find and Replace in Unity Assets

Directly change serialized field name LevelId to levelId in all scenes. Requires Unity Force Text serialization.

Requires GNU tools. Tested on OSX. Note Windows @code users can run WSL Linux directly in the editor terminal!

Find Product Scenes

find -type f -wholename '*/Assets/Sinkr/*.unity' -exec ls -la '{}' \;
find -type f -wholename '*/Assets/Sinkr2/*.unity' -exec ls -la '{}' \;
find -type f -wholename '*/Assets/Test/*.unity' -exec ls -la '{}' \;
find -type f -wholename '*/products/Sinkr/*.unity' -exec ls -la '{}' \;

Determine if Product Scenes need changes

find -type f -wholename '*/Assets/Sinkr/*.unity' -exec grep 'propertyPath: LevelId' '{}' \;
find -type f -wholename '*/Assets/Sinkr2/*.unity' -exec grep 'propertyPath: LevelId' '{}' \;
find -type f -wholename '*/Assets/Test/*.unity' -exec grep 'propertyPath: LevelId' '{}' \;
find -type f -wholename '*/products/Sinkr/*.unity' -exec grep 'propertyPath: LevelId' '{}' \;

Replace in Product Scenes

find -type f -wholename '*/Assets/Sinkr/*.unity' -exec sed -i 's/propertyPath: LevelId/propertyPath: levelId/g' '{}' \;
find -type f -wholename '*/Assets/Sinkr2/*.unity' -exec sed -i 's/propertyPath: LevelId/propertyPath: levelId/g' '{}' \;
find -type f -wholename '*/Assets/Test/*.unity' -exec sed -i 's/propertyPath: LevelId/propertyPath: levelId/g' '{}' \;
find -type f -wholename '*/products/Sinkr/*.unity' -exec sed -i 's/propertyPath: LevelId/propertyPath: levelId/g' '{}' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment