Skip to content

Instantly share code, notes, and snippets.

@jaburns
Last active September 8, 2016 04:23
Show Gist options
  • Save jaburns/82a820e79c38874109d7 to your computer and use it in GitHub Desktop.
Save jaburns/82a820e79c38874109d7 to your computer and use it in GitHub Desktop.
Find scene and prefab references to scripts in Unity.
#!/usr/bin/env bash
#
# Run from the project root. Pass the full name of a script, or substring of the names of the scripts to check.
#
# Example
# $) ./findrefs.sh BackgroundCamera
# Finding matches for script Assets/Scripts/Camera/BackgroundCamera.cs.meta ...
# Assets/Prefabs/CaveBGCamera.prefab: m_Script: {fileID: 11500000, guid: 7e63acfee367c4314852b87218149bd3, type: 3}
# Assets/Prefabs/ForestBGCamera.prefab: m_Script: {fileID: 11500000, guid: 7e63acfee367c4314852b87218149bd3, type: 3}
#
# $)
find_refs() {
echo "Finding matches for script $1 ..."
local guid="$(grep guid "$line" | sed 's/^.* //')"
grep -R "$guid" Assets | grep -v "$1"
echo ""
}
find Assets -iname "*$1*.cs.meta" | while read line; do
find_refs "$line"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment