forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatchImportSettingRecycleID.cs
More file actions
48 lines (45 loc) · 1.65 KB
/
PatchImportSettingRecycleID.cs
File metadata and controls
48 lines (45 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections;
using UnityEditor;
internal class PatchImportSettingRecycleID
{
public static void Patch(SerializedObject serializedObject, int classID, string oldName, string newName)
{
string[] oldNames = new string[] { oldName };
string[] newNames = new string[] { newName };
PatchMultiple(serializedObject, classID, oldNames, newNames);
}
public static void PatchMultiple(SerializedObject serializedObject, int classID, string[] oldNames, string[] newNames)
{
int length = oldNames.Length;
IEnumerator enumerator = serializedObject.FindProperty("m_FileIDToRecycleName").GetEnumerator();
try
{
while (enumerator.MoveNext())
{
SerializedProperty current = (SerializedProperty) enumerator.Current;
if (AssetImporter.LocalFileIDToClassID(current.FindPropertyRelative("first").longValue) == classID)
{
SerializedProperty property4 = current.FindPropertyRelative("second");
int index = Array.IndexOf<string>(oldNames, property4.stringValue);
if (index >= 0)
{
property4.stringValue = newNames[index];
if (--length == 0)
{
return;
}
}
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
}