UnityEditor.EditorUtility.NaturalCompare C# (CSharp) Method

NaturalCompare() private method

private NaturalCompare ( string a, string b ) : int
a string
b string
return int
        public static extern int NaturalCompare(string a, string b);
        [MethodImpl(MethodImplOptions.InternalCall)]

Usage Example

示例#1
0
        static bool CreateAnimation(GameObject gameObject, Object[] frames, ShowFileDialogDelegate saveFileDialog)
        {
            saveFileDialog = saveFileDialog ?? EditorUtility.SaveFilePanelInProject;

            // Use same name compare as when we sort in the backend: See AssetDatabase.cpp: SortChildren
            System.Array.Sort(frames, (a, b) => EditorUtility.NaturalCompare(a.name, b.name));

            Animator animator = AnimationWindowUtility.EnsureActiveAnimationPlayer(gameObject)
                ? AnimationWindowUtility.GetClosestAnimatorInParents(gameObject.transform)
                : null;

            bool createSuccess = animator != null;

            if (animator != null)
            {
                // Go forward with presenting user a save clip dialog
                string message          = string.Format(SpriteUtilityStrings.saveAnimDialogMessage.text, gameObject.name);
                string newClipDirectory = ProjectWindowUtil.GetActiveFolderPath();
                string newClipPath      = saveFileDialog(SpriteUtilityStrings.saveAnimDialogTitle.text, SpriteUtilityStrings.saveAnimDialogName.text, "anim", message, newClipDirectory);

                if (string.IsNullOrEmpty(newClipPath))
                {
                    Undo.ClearUndo(animator);
                    Object.DestroyImmediate(animator);
                    return(false);
                }
                else
                {
                    AnimationClip newClip = AnimationWindowUtility.CreateNewClipAtPath(newClipPath);
                    if (newClip != null)
                    {
                        AddSpriteAnimationToClip(newClip, frames);
                        createSuccess = AnimationWindowUtility.AddClipToAnimatorComponent(animator, newClip);
                    }
                }
            }

            if (createSuccess == false)
            {
                Debug.LogError(SpriteUtilityStrings.failedToCreateAnimationError.text);
            }

            return(createSuccess);
        }
All Usage Examples Of UnityEditor.EditorUtility::NaturalCompare
EditorUtility