如何判斷一個物體下是否有子物體?getchild(0)!=null?顯然不可取
那去獲取拿到子物體數量?transform.GetChildCount();可以解決
但在新版本中已被棄用,可用transform.childCount來直接獲取子物體數量。
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Example() { print(transform.childCount); } }