Skip to content

Commit af4ad4c

Browse files
committed
create array of all ids that need to be replaced
1 parent 2735921 commit af4ad4c

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

Assets/com.unity.formats.fbx/Editor/Scripts/FbxExporterRepairMissingScripts.cs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,18 @@ public class RepairMissingScripts
1515

1616
private const string m_idFormat = "{{fileID: {0}, guid: {1}, type:";
1717

18-
private static string m_forumPackageSearchID;
19-
private static string ForumPackageSearchID {
20-
get {
21-
if (string.IsNullOrEmpty (m_forumPackageSearchID)) {
22-
m_forumPackageSearchID = string.Format (m_idFormat, m_fbxPrefabDLLFileId, m_forumPackageGUID);
23-
}
24-
return m_forumPackageSearchID;
25-
}
26-
}
27-
28-
private static string m_assetStorePackageSearchID;
29-
private static string AssetStorePackageSearchID {
30-
get {
31-
if (string.IsNullOrEmpty (m_assetStorePackageSearchID)) {
32-
m_assetStorePackageSearchID = string.Format (m_idFormat, m_fbxPrefabDLLFileId, m_assetStorePackageGUID);
18+
private static List<string> m_searchIDsToReplace;
19+
private static string[] SearchIDsToReplace
20+
{
21+
get
22+
{
23+
if(m_searchIDsToReplace == null || m_searchIDsToReplace.Count <= 0)
24+
{
25+
m_searchIDsToReplace = new List<string>();
26+
m_searchIDsToReplace.Add(string.Format(m_idFormat, m_fbxPrefabDLLFileId, m_forumPackageGUID));
27+
m_searchIDsToReplace.Add(string.Format(m_idFormat, m_fbxPrefabDLLFileId, m_assetStorePackageGUID));
3328
}
34-
return m_assetStorePackageSearchID;
29+
return m_searchIDsToReplace.ToArray();
3530
}
3631
}
3732

@@ -103,9 +98,13 @@ private static bool AssetNeedsRepair(string filePath)
10398
}
10499

105100
var contents = sr.ReadToEnd();
106-
if(contents.Contains(ForumPackageSearchID) || contents.Contains(AssetStorePackageSearchID)){
107-
sr.Close();
108-
return true;
101+
foreach(var searchId in SearchIDsToReplace)
102+
{
103+
if (contents.Contains(searchId))
104+
{
105+
sr.Close();
106+
return true;
107+
}
109108
}
110109
}
111110
}
@@ -162,15 +161,13 @@ private static bool ReplaceGUIDInFile (string path, string replacementSearchID)
162161
while (sr.Peek () > -1) {
163162
var line = sr.ReadLine ();
164163

165-
if (line.Contains (ForumPackageSearchID)) {
166-
line = line.Replace (ForumPackageSearchID, replacementSearchID);
167-
modified = true;
168-
}
169-
170-
if (line.Contains(AssetStorePackageSearchID))
164+
foreach(var searchId in SearchIDsToReplace)
171165
{
172-
line = line.Replace (AssetStorePackageSearchID, replacementSearchID);
173-
modified = true;
166+
if (line.Contains(searchId))
167+
{
168+
line = line.Replace(searchId, replacementSearchID);
169+
modified = true;
170+
}
174171
}
175172

176173
sw.WriteLine (line);

0 commit comments

Comments
 (0)