獲得所有子物體
網上查的是
foreach (Transform child in transform)
{
Debug.Log(child.gameObject.name);
}
應該避免使用foreach,會有以下兩個問題
1. 慢。foreach調用GC Alloc。
2. 不能更改集合中內容以避免不可預知錯誤。
所以還是用for循環比較好,找了下transform接口,這樣寫應該可以
for (int i = 0; i < transform.childCount; i++)
{
<span style="white-space:pre"> </span>Debug.Log(transform.GetChild(i).name)
}
點擊邊緣任意位子關閉當前面板
<span style="white-space:pre"> </span>Ray ray;
ray = Camera.allCameras[1].ScreenPointToRay(new Vector3(m_lastClickPos.x, m_lastClickPos.y, 0));
RaycastHit hit;
if (Physics.Raycast(ray, out hit))//函數是對射線碰撞的檢測
{
Vector3 Point = hit.point;//得到碰撞點的座標
<span style="white-space:pre"> </span>print("碰撞的是:" + hit.collider.gameObject.name);
<span style="white-space:pre"> </span>}
NGUI——UILabel不同格式字體
[i]italic[/i]
[u]underline[/u]
[s]strikethrough[/s]