void ToolSelection() { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Input.GetMouseButton(0) && PlanetStatistics.toolSelection != 3) { if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { // Raise Terrain if (PlanetStatistics.mainSelection == 0 && PlanetStatistics.toolSelection == 0) { MeshFilter filter = hit.collider.GetComponent <MeshFilter>(); if (filter) { if (filter != ToolsClass.unappliedMesh) { ToolsClass.unappliedMesh = filter; } // Deform mesh var relativePoint = filter.transform.InverseTransformPoint(hit.point); ToolsClass.DeformMesh(filter.mesh, relativePoint, PlanetStatistics.brushStrength * Time.deltaTime, PlanetStatistics.brushSize); } } // Lower Terrain if (PlanetStatistics.mainSelection == 0 && PlanetStatistics.toolSelection == 1) { MeshFilter filter = hit.collider.GetComponent <MeshFilter>(); if (filter) { if (filter != ToolsClass.unappliedMesh) { ToolsClass.unappliedMesh = filter; } // Deform mesh var relativePoint = filter.transform.InverseTransformPoint(hit.point); ToolsClass.DeformMesh(filter.mesh, relativePoint, -PlanetStatistics.brushStrength * Time.deltaTime, PlanetStatistics.brushSize); } } // Flatten Terrain. if (PlanetStatistics.mainSelection == 0 && PlanetStatistics.toolSelection == 2) { MeshFilter filter = hit.collider.GetComponent <MeshFilter>(); if (filter) { if (filter != ToolsClass.unappliedMesh) { ToolsClass.unappliedMesh = filter; } var relativePoint = filter.transform.InverseTransformPoint(hit.point); ToolsClass.FlattenMesh(hit.transform, filter.mesh, relativePoint, PlanetStatistics.brushStrength * Time.deltaTime, PlanetStatistics.altitude, PlanetStatistics.brushSize); } } } // Raycast } // Input mouse(0) if (Input.GetMouseButtonUp(0)) { ApplyMeshCollider(); if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { MeshFilter filter = hit.collider.GetComponent <MeshFilter>(); if (PlanetStatistics.mainSelection == 1) { if (PlanetStatistics.propSelection == 0) { ToolsClass.PlaceGroupProp(filter.mesh, gameObject, oneProps[PlanetStatistics.propOneType] as GameObject, hit.point, PlanetStatistics.brushSize, PlanetStatistics.amountOfObjects); } if (PlanetStatistics.propSelection == 1) { ToolsClass.PlaceGroupProp(filter.mesh, gameObject, twoProps[PlanetStatistics.propTwoType] as GameObject, hit.point, PlanetStatistics.brushSize, PlanetStatistics.amountOfObjects); } if (PlanetStatistics.propSelection == 2) { ToolsClass.PlaceGroupProp(filter.mesh, gameObject, threeProps[PlanetStatistics.propThreeType] as GameObject, hit.point, PlanetStatistics.brushSize, PlanetStatistics.amountOfObjects); } if (PlanetStatistics.propSelection == 3) { ToolsClass.PlaceGroupProp(filter.mesh, gameObject, fourProps[PlanetStatistics.propFourType] as GameObject, hit.point, PlanetStatistics.brushSize, PlanetStatistics.amountOfObjects); } } } } }