@@ -9,14 +9,13 @@ namespace FbxExporters.Editor
9
9
public class RepairMissingScripts
10
10
{
11
11
private const string m_forumPackageGUID = "2d81c55c4d9d85146b1d2de96e084b63" ;
12
- private const string m_currentPackageGUID = "628ffbda3fdf4df4588770785d91a698" ;
12
+ private const string m_assetStorePackageGUID = "628ffbda3fdf4df4588770785d91a698" ;
13
13
14
14
private const string m_fbxPrefabDLLFileId = "69888640" ;
15
15
16
16
private const string m_idFormat = "{{fileID: {0}, guid: {1}, type:" ;
17
17
18
18
private static string m_forumPackageSearchID ;
19
-
20
19
private static string ForumPackageSearchID {
21
20
get {
22
21
if ( string . IsNullOrEmpty ( m_forumPackageSearchID ) ) {
@@ -26,14 +25,13 @@ private static string ForumPackageSearchID {
26
25
}
27
26
}
28
27
29
- private static string m_currentPackageSearchID ;
30
-
31
- private static string CurrentPackageSearchID {
28
+ private static string m_assetStorePackageSearchID ;
29
+ private static string AssetStorePackageSearchID {
32
30
get {
33
- if ( string . IsNullOrEmpty ( m_currentPackageSearchID ) ) {
34
- m_currentPackageSearchID = string . Format ( m_idFormat , m_fbxPrefabDLLFileId , m_currentPackageGUID ) ;
31
+ if ( string . IsNullOrEmpty ( m_assetStorePackageSearchID ) ) {
32
+ m_assetStorePackageSearchID = string . Format ( m_idFormat , m_fbxPrefabDLLFileId , m_assetStorePackageGUID ) ;
35
33
}
36
- return m_currentPackageSearchID ;
34
+ return m_assetStorePackageSearchID ;
37
35
}
38
36
}
39
37
@@ -47,6 +45,20 @@ private string[] AssetsToRepair{
47
45
}
48
46
}
49
47
48
+ public static bool TryGetSourceCodeSearchID ( out string searchID )
49
+ {
50
+ var fbxPrefabObj = AssetDatabase . LoadMainAssetAtPath ( FbxExporters . FbxPrefabAutoUpdater . FindFbxPrefabAssetPath ( ) ) ;
51
+ searchID = null ;
52
+ string guid ;
53
+ long fileId ;
54
+ if ( AssetDatabase . TryGetGUIDAndLocalFileIdentifier ( fbxPrefabObj , out guid , out fileId ) )
55
+ {
56
+ searchID = string . Format ( m_idFormat , fileId , guid ) ;
57
+ return true ;
58
+ }
59
+ return false ;
60
+ }
61
+
50
62
public int GetAssetsToRepairCount ( ) {
51
63
return AssetsToRepair . Length ;
52
64
}
@@ -91,7 +103,7 @@ private static bool AssetNeedsRepair(string filePath)
91
103
}
92
104
93
105
var contents = sr . ReadToEnd ( ) ;
94
- if ( contents . Contains ( ForumPackageSearchID ) ) {
106
+ if ( contents . Contains ( ForumPackageSearchID ) || contents . Contains ( AssetStorePackageSearchID ) ) {
95
107
sr . Close ( ) ;
96
108
return true ;
97
109
}
@@ -105,17 +117,22 @@ private static bool AssetNeedsRepair(string filePath)
105
117
106
118
public bool ReplaceGUIDInTextAssets ( )
107
119
{
120
+ string sourceCodeSearchID ;
121
+ if ( ! TryGetSourceCodeSearchID ( out sourceCodeSearchID ) )
122
+ {
123
+ return false ;
124
+ }
108
125
bool replacedGUID = false ;
109
126
foreach ( string file in AssetsToRepair ) {
110
- replacedGUID |= ReplaceGUIDInFile ( file ) ;
127
+ replacedGUID |= ReplaceGUIDInFile ( file , sourceCodeSearchID ) ;
111
128
}
112
129
if ( replacedGUID ) {
113
130
AssetDatabase . Refresh ( ) ;
114
131
}
115
132
return replacedGUID ;
116
133
}
117
134
118
- private static bool ReplaceGUIDInFile ( string path )
135
+ private static bool ReplaceGUIDInFile ( string path , string replacementSearchID )
119
136
{
120
137
// try to read file, assume it's a text file for now
121
138
bool modified = false ;
@@ -146,7 +163,13 @@ private static bool ReplaceGUIDInFile (string path)
146
163
var line = sr . ReadLine ( ) ;
147
164
148
165
if ( line . Contains ( ForumPackageSearchID ) ) {
149
- line = line . Replace ( ForumPackageSearchID , CurrentPackageSearchID ) ;
166
+ line = line . Replace ( ForumPackageSearchID , replacementSearchID ) ;
167
+ modified = true ;
168
+ }
169
+
170
+ if ( line . Contains ( AssetStorePackageSearchID ) )
171
+ {
172
+ line = line . Replace ( AssetStorePackageSearchID , replacementSearchID ) ;
150
173
modified = true ;
151
174
}
152
175
0 commit comments