文章转载至:http://www.seven-fire.cn/archives/179
命名空间的引用:
using UnityEngine;
using UnityEditor;
放在Editor文件夹下即可
<span style="font-family:宋体;"><span style="color:#696969;">按字母</span>升序排列
public class AscendingSort : BaseHierarchySort {
public override int Compare( GameObject lhs , GameObject rhs) {
if (lhs == rhs) { return 0; }
if (lhs == null) { return -1; }
if (rhs == null) { return 1; }
return EditorUtility .NaturalCompare( lhs.name , rhs.name);
}
}</span>
按字母降序排列
public class DescendingSort : BaseHierarchySort {
public override int Compare( GameObject lhs , GameObject rhs) {
if (lhs == rhs) { return 0; }
if (lhs == null) { return 1; }
if (rhs == null) { return -1; }
return EditorUtility .NaturalCompare( rhs.name , lhs.name);
}
}
public class 升序排列 : BaseHierarchySort
{
public override int Compare( GameObject lhs , GameObject rhs)
{
if (lhs == rhs) { return 0; }
if (lhs == null) { return -1; }
if (rhs == null) { return 1; }
return EditorUtility .NaturalCompare( lhs.name , rhs.name);
}
public override GUIContent content {
get { return new GUIContent( "升序"); }
}
}
来源:CSDN
作者:Unity_阿黄
链接:https://blog.csdn.net/ldy597321444/article/details/51879006