Last active
August 29, 2015 14:13
-
-
Save zaki/43db93b8e2046737764b to your computer and use it in GitHub Desktop.
Find missing script references in unity prefabs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
guids = {} | |
dir = File.dirname(__FILE__) + "/../../unity/Assets/**/*.meta" | |
Dir.glob(dir, File::FNM_DOTMATCH).each do |script| | |
if File.read(script) =~ /guid: ([\h]+$)/m | |
guids[$1] = $1 | |
end | |
end | |
dir = File.dirname(__FILE__) + "/../../unity/Assets/**/*.prefab" | |
Dir.glob(dir, File::FNM_DOTMATCH).each do |prefab| | |
if File.read(prefab) =~ /m_Script: {.*guid: ([\h]+),/ | |
puts "Possibly missing script in prefab #{prefab} guid #{$1}" unless guids[$1] | |
end | |
end | |
dir = File.dirname(__FILE__) + "/../../unity/Assets/**/*.unity" | |
Dir.glob(dir, File::FNM_DOTMATCH).each do |prefab| | |
if File.read(prefab) =~ /m_Script: {.*guid: ([\h]+),/ | |
puts "Possibly missing script in scene #{prefab} guid #{$1}" unless guids[$1] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment