How do I fill a Sprite[] in the alphabetical order in the script Inspector?
Okay this is infuriating. I have Sprite files called "frame (x)" where x is the frame number. When I drag and drop all the frames on a Sprite array in the inspector it adds them in a random order... I want them to be added in chronological order meaning "frame (1)" then "frame (2)" but it decides to put them in a random fashion like so:
Answer by Kourbou · Aug 22, 2015 at 10:33 AM
Nevermind I found a working answer: http://answers.unity3d.com/questions/542655/add-elements-in-array-in-inspector-with-alphabetic.html
[ContextMenu ("Sort Frames by Name")]
void DoSortFrames() {
System.Array.Sort(frames, (a,b) => a.name.CompareTo(b.name));
Debug.Log(gameObject.name + ".frames have been sorted alphabetically.");
}
Your answer
Follow this Question
Related Questions
SpriteRenderer.sprite change from Sprite array is not working 1 Answer
[C#] Array out of bounds 1 Answer
how do i script for the script to check the transform on the first animation(Javascript) 0 Answers
Unity Inspector public large array - Lag and errors - Optimized GUI Block text buffer too large 0 Answers
the image set on the inspector is not displayed. I am a beginner 2 Answers