示例#1
0
    GameObject CreateBlock(GameObject _prefab, Vector3 _position, float _yRotation)
    {
        GameObject newInst = Instantiate(_prefab);

        newInst.transform.position = _position;
        newInst.transform.RotateAround(newInst.transform.position, Vector3.up, _yRotation);
        newInst.transform.SetParent(transform, false);
        GOData goD = newInst.AddComponent <GOData>();

        goD.blockTypeName = _prefab.name;
        goD.position      = newInst.transform.position;
        goD.yRotation     = _yRotation;
        newInst.name      = _prefab.name + ", X:" + newInst.transform.position.x + ", Y:" + newInst.transform.position.y + ", Z:" + newInst.transform.position.z;
        newInst.GetComponentInChildren <MeshRenderer>().gameObject.AddComponent <NavMeshSourceTag>();
        Util.AddAllMeshCollidersToRenderers(newInst);
        mapData.Add(newInst);
        return(newInst);
    }