【Unity】Hierarchy面板排序
发表于2017-08-28
层级(Hierarchy)面板包括所有在当前游戏场景的GameObject,但有些人可能对Hierarchy面板排序可能不了解,为此下面就给大家详细介绍下。
命名空间的引用:
using UnityEngine;
using UnityEditor;
放在Editor文件夹下即可
- <span style=< span="">"font-family:宋体;"><span style=< span="">"color:#696969;">按字母升序排列 </span style=<></span style=<>
- 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);
- }
- }
- 按字母降序排列
- 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);
- }
- } copy
- 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( "升序"); }
- }
- }