獲取子物體數量---Transform.childCount


如何判斷一個物體下是否有子物體?getchild(0)!=null?顯然不可取

那去獲取拿到子物體數量?transform.GetChildCount();可以解決

但在新版本中已被棄用,可用transform.childCount來直接獲取子物體數量。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
        print(transform.childCount);
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM