Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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