Unity查找自身为第几个子物体GetSiblingIndex()


1.API  GetSiblingIndex(); Gets the sibling index

直接挂到 四个按钮上  即可看到每一个按钮的索引 (也就是Canvas下面有几个子物体 索引从0开始)

 

 代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GetChild_ID : MonoBehaviour
{
    public int IDD;
    public  Transform parent;
    // Start is called before the first frame update
    void Start()
    {
        parent = this.transform.parent;
        IDD = this.transform.GetSiblingIndex();
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM