示例#1
0
    private GameObject ObtainChildObject(string objectName)
    {
        Transform[] children = agent.GetComponentsInChildren <Transform>();
        for (int i = 0; i < children.Length; i++)
        {
            if (children[i].name == objectName)
            {
                return(children[i].gameObject);
            }
        }

        GameObject childObject = new GameObject(objectName);

        childObject.transform.SetParent(agent.transform);

        return(childObject);
    }