Odin Attributes 为Unity开发者提供了更多的自定义选项,使得开发过程更加高效和愉悦。通过使用这些特性,开发者可以创建更加专业和用户友好的编辑器界面,从而提升整个开发团队的工作效率。

Child Game Objects Only特性可用于 Components 和 GameObject 字段,并将在对象字段旁边预置一个小按钮,该按钮将在所有子游戏对象中搜索可分配对象,并将它们显示在下拉列表中供用户选择。
1.【ChildGameObjectsOnly】获取包括自己在内以的可用节点
[ChildGameObjectsOnly]
public GameObject ChildGameObject;

2.【IncludeSelf】是否包含自己的节点
[ChildGameObjectsOnly(IncludeSelf = false)]//是否包含顶层定节点
public Transform ChildOrSelfTransform;

完整示例代码
using UnityEngine;
using Sirenix.OdinInspector;
public class ChildGameObjectsOnlyAttributeExample : MonoBehaviour
{
[ChildGameObjectsOnly(IncludeSelf = false)]//是否包含顶层定节点
public Transform ChildOrSelfTransform;
[ChildGameObjectsOnly]
public GameObject ChildGameObject;
[ChildGameObjectsOnly(IncludeSelf = false)]
public Light[] Lights;
public void Start()
{
Debug.Log(ChildOrSelfTransform);
Debug.Log(ChildGameObject);
}
}
930

被折叠的 条评论
为什么被折叠?



