用于Components和GameObject字段,并將在對象字段旁邊添加一個小按鈕本涕,該按鈕將在所有子游戲?qū)ο笾兴阉骺煞峙鋵ο蟾襞⑵滹@示在下拉列表中供用戶選擇。
【ChildGameObjectsOnly】獲取包括自己在內(nèi)以的可用節(jié)點
[ChildGameObjectsOnly]
public GameObject ChildGameObject;
【IncludeSelf】是否包含自己的節(jié)點
[ChildGameObjectsOnly(IncludeSelf = false)]//是否包含頂層定節(jié)點
public Transform ChildOrSelfTransform;
完整示例代碼
using UnityEngine;
using Sirenix.OdinInspector;
public class ChildGameObjectsOnlyAttributeExample : MonoBehaviour
{
[ChildGameObjectsOnly(IncludeSelf = false)]//是否包含頂層定節(jié)點
public Transform ChildOrSelfTransform;
[ChildGameObjectsOnly]
public GameObject ChildGameObject;
[ChildGameObjectsOnly(IncludeSelf = false)]
public Light[] Lights;
public void Start()
{
Debug.Log(ChildOrSelfTransform);
Debug.Log(ChildGameObject);
}
}