void makeBuildings(Vector2 v) { Vector3 down = transform.TransformDirection(Vector3.down); RaycastHit hit; if (Physics.Raycast(new Vector3((v.x) * cubeSize + (position.x - 1 / 2) * 20 * cubeSize, 300f, ((v.y) * cubeSize + (position.y - 1 / 2) * 20 * cubeSize)) , down, out hit) && (hit.collider == cube.GetComponent <Collider>() as Collider)) { GameObject buildingA = Instantiate(building); CylBuildingMaker cbm = buildingA.GetComponent <CylBuildingMaker> () as CylBuildingMaker; MeshCollider c = buildingA.GetComponent <MeshCollider> () as MeshCollider; //Set each component of a tree and Instantiate here /*cbm.faces = new int[1]; * cbm.radius = 1; * cbm.segments = 1; * cbm.segmentHeight = 1; * cbm.topChances = new float[1]; * cbm.expandChance = 1; * cbm.windowChance = 1; * cbm.maxRad = new float[1]; * cbm.windowHeight = 1; * cbm.windowInset = 1;*/ //building.transform.parent = buildingParent.transform cbm.BuildMe(); buildingA.transform.parent = BuildingContainer.transform; buildingA.transform.position = hit.point; buildingA.SetActive(true); c.sharedMesh = buildingA.GetComponent <MeshFilter> ().mesh; } }
// Use this for initialization void Start() { CylBuildingMaker cbm = gameObject.GetComponent <CylBuildingMaker> () as CylBuildingMaker; cbm.BuildMe(); }