示例#1
0
    /// <summary>
    /// 注册场景中的碰撞器到物理系统
    /// </summary>
    void RegistSceneCollider(string tPath, Transform tTrans)
    {
        Transform parent = null;

        if (!string.IsNullOrEmpty(tPath))
        {
            parent = GameObject.Find(tPath).transform;
        }
        else
        {
            parent = tTrans;
        }

        if (parent == null)
        {
            return;
        }

        int count = parent.childCount;

        for (int i = 0; i < count; i++)
        {
            Transform      child    = parent.GetChild(i);
            CustomCollider collider = child.GetComponent <CustomCollider>();
            if (collider != null)
            {
                collider.mIsobstacle = true;
                if (child.gameObject.activeInHierarchy)
                {
                    collider.Regist();
                }
            }
            if (child.childCount > 0)
            {
                RegistSceneCollider(null, child);
            }
        }
    }