Hi all,
I have two arrays, one with a bunch of meshes in, and another with some textures. I have a script that cycles through both to create a 3D animation. However, even though all the assets are very nicely named, and are listed in the correct order under project view, as soon as I drag them into the inspector they become jumbled. As such I’m trying to create an editor script that will perform a bubble sort for a serializedproperty array. I made one that sorts through an array of ints already:
EditorGUILayout.PropertyField(testArray, new GUIContent("Test Array"), true);
if(GUILayout.Button("Sort Array")) {
int lastVal, moveCount;
for(int i = 0; i < 5000; i++) {
moveCount = 0;
lastVal = testArray.GetArrayElementAtIndex(0).intValue;
for( int j = 1; j < testArray.arraySize; j++ ) {
if(testArray.GetArrayElementAtIndex(j).intValue < lastVal) {
moveCount++;
testArray.MoveArrayElement(j, j - 1);
}
lastVal = testArray.GetArrayElementAtIndex(j).intValue;
}
if(moveCount == 0) { break; }
}
}
The issue is that there’s no equivalent of ‘intValue’ for the other arrays. There is something called ‘name’, but it doesn’t return anything usable (if I try to output this to console, it just says ‘data’). Any ideas / suggestions would be much appreciated.
Thanks, Liam