private Vertex2DMetaData[] LoadVertex2DMetaData(SerializedObject importer, SpriteImportMode mode, int index) { var so = mode == SpriteImportMode.Multiple ? importer.FindProperty("m_SpriteSheet.m_Sprites").GetArrayElementAtIndex(index) : importer.FindProperty("m_SpriteSheet"); var verticesSP = so.FindPropertyRelative("m_Vertices"); var weightsSP = so.FindPropertyRelative("m_Weights"); var vertices = new Vertex2DMetaData[verticesSP.arraySize]; for (int i = 0; i < verticesSP.arraySize; ++i) { var vsp = verticesSP.GetArrayElementAtIndex(i); var wsp = weightsSP.GetArrayElementAtIndex(i); vertices[i] = new Vertex2DMetaData { position = vsp.vector2Value, boneWeight = new BoneWeight { weight0 = wsp.FindPropertyRelative("weight[0]").floatValue, weight1 = wsp.FindPropertyRelative("weight[1]").floatValue, weight2 = wsp.FindPropertyRelative("weight[2]").floatValue, weight3 = wsp.FindPropertyRelative("weight[3]").floatValue, boneIndex0 = wsp.FindPropertyRelative("boneIndex[0]").intValue, boneIndex1 = wsp.FindPropertyRelative("boneIndex[1]").intValue, boneIndex2 = wsp.FindPropertyRelative("boneIndex[2]").intValue, boneIndex3 = wsp.FindPropertyRelative("boneIndex[3]").intValue } }; } return(vertices); }
private Vertex2DMetaData[] LoadVertex2DMetaData(SerializedObject importer, SpriteImportMode mode, int index) { SerializedProperty serializedProperty = (mode != SpriteImportMode.Multiple) ? importer.FindProperty("m_SpriteSheet") : importer.FindProperty("m_SpriteSheet.m_Sprites").GetArrayElementAtIndex(index); SerializedProperty serializedProperty2 = serializedProperty.FindPropertyRelative("m_Vertices"); SerializedProperty serializedProperty3 = serializedProperty.FindPropertyRelative("m_Weights"); Vertex2DMetaData[] array = new Vertex2DMetaData[serializedProperty2.arraySize]; for (int i = 0; i < serializedProperty2.arraySize; i++) { SerializedProperty arrayElementAtIndex = serializedProperty2.GetArrayElementAtIndex(i); SerializedProperty arrayElementAtIndex2 = serializedProperty3.GetArrayElementAtIndex(i); array[i] = new Vertex2DMetaData { position = arrayElementAtIndex.vector2Value, boneWeight = new BoneWeight { weight0 = arrayElementAtIndex2.FindPropertyRelative("weight[0]").floatValue, weight1 = arrayElementAtIndex2.FindPropertyRelative("weight[1]").floatValue, weight2 = arrayElementAtIndex2.FindPropertyRelative("weight[2]").floatValue, weight3 = arrayElementAtIndex2.FindPropertyRelative("weight[3]").floatValue, boneIndex0 = arrayElementAtIndex2.FindPropertyRelative("boneIndex[0]").intValue, boneIndex1 = arrayElementAtIndex2.FindPropertyRelative("boneIndex[1]").intValue, boneIndex2 = arrayElementAtIndex2.FindPropertyRelative("boneIndex[2]").intValue, boneIndex3 = arrayElementAtIndex2.FindPropertyRelative("boneIndex[3]").intValue } }; } return(array); }