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();
            }
        }
    }
	public static void PatchMultiple(SerializedObject serializedObject, int classID, string[] oldNames, string[] newNames)
	{
		int num = oldNames.Length;
		SerializedProperty serializedProperty = serializedObject.FindProperty("m_FileIDToRecycleName");
		foreach (SerializedProperty serializedProperty2 in serializedProperty)
		{
			SerializedProperty serializedProperty3 = serializedProperty2.FindPropertyRelative("first");
			if (AssetImporter.LocalFileIDToClassID(serializedProperty3.longValue) == classID)
			{
				SerializedProperty serializedProperty4 = serializedProperty2.FindPropertyRelative("second");
				int num2 = Array.IndexOf<string>(oldNames, serializedProperty4.stringValue);
				if (num2 >= 0)
				{
					serializedProperty4.stringValue = newNames[num2];
					if (--num == 0)
					{
						break;
					}
				}
			}
		}
	}
Пример #3
0
    // Patches multiple entries at once to avoid situations where swapping names of two entries would break references
    static public void PatchMultiple(SerializedObject serializedObject, int classID, string[] oldNames, string[] newNames)
    {
        int left = oldNames.Length;

        SerializedProperty recycleMap = serializedObject.FindProperty("m_FileIDToRecycleName");

        foreach (SerializedProperty element in recycleMap)
        {
            SerializedProperty first = element.FindPropertyRelative("first");
            if (AssetImporter.LocalFileIDToClassID(first.longValue) == classID)
            {
                SerializedProperty second = element.FindPropertyRelative("second");
                int idx = Array.IndexOf(oldNames, second.stringValue);
                if (idx >= 0)
                {
                    second.stringValue = newNames[idx];
                    if (--left == 0)
                    {
                        break;
                    }
                }
            }
        }
    }
Пример #4
0
    public static void PatchMultiple(SerializedObject serializedObject, int classID, string[] oldNames, string[] newNames)
    {
        int num = oldNames.Length;
        SerializedProperty serializedProperty = serializedObject.FindProperty("m_FileIDToRecycleName");
        IEnumerator        enumerator         = serializedProperty.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                SerializedProperty serializedProperty2 = (SerializedProperty)enumerator.Current;
                SerializedProperty serializedProperty3 = serializedProperty2.FindPropertyRelative("first");
                if (AssetImporter.LocalFileIDToClassID(serializedProperty3.longValue) == classID)
                {
                    SerializedProperty serializedProperty4 = serializedProperty2.FindPropertyRelative("second");
                    int num2 = Array.IndexOf <string>(oldNames, serializedProperty4.stringValue);
                    if (num2 >= 0)
                    {
                        serializedProperty4.stringValue = newNames[num2];
                        if (--num == 0)
                        {
                            break;
                        }
                    }
                }
            }
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
    }