登录
  • 欢迎访问 Sharezer Blog

Hierarchy排序

Editor sharezer 3068次浏览 已收录 0个评论

   Hierarchy排序

using UnityEditor;
using UnityEngine;

public class 升序排列 : BaseHierarchySort
{
    public override GUIContent content
    {
        get { return new GUIContent("升序"); }
    }

    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 降序排列 : BaseHierarchySort
{
    public override GUIContent content
    {
        get { return new GUIContent("降序"); }
    }

    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);
    }
}


Sharezer , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Hierarchy排序
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址