- Home /
Smooth draw curve line
![alt text][1]Hello There I made the code for drawing the curve on the PC. The photo below is a photograph of a PC. [1]: /storage/temp/44338-triangle.png The second photo is a picture of the Android. [2]: /storage/temp/44340-tri.png This line is not smooth line segment by creating one triangle in Android. In the PC segment looks like a smooth line looks like two overlapping squares, but triangles And the work by drawing a smooth curve from the current Android. I want to get help. Please Help me. I want to smooth curve line in android.
The Code :
using UnityEngine; using System.Collections; using System.Collections.Generic; public class StrightLine : MonoBehaviour { private LineRenderer line; // Reference to LineRenderer private Vector3 mousePos;
private Vector3 startPos; // Start position of line private Vector3 endPos; // End position of line private List pointList; public GameObject ball; public Shader shader; private bool isMousepressed; private Rigidbody2D ri; void start(){
}
void Update ()
{
// On mouse down new line will be created
if(Input.GetMouseButtonDown(0))
{
if(line == null)
createLine();
pointList.RemoveRange(0,pointList.Count);
isMousepressed=true;
}
else if(Input.GetMouseButtonUp(0))
{
if(line)
{
line = null;
isMousepressed=false;
}
}
else if(isMousepressed)
{
mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = 0;
if(line)
{
pointList.Add (mousePos);
line.SetVertexCount (pointList.Count);
line.SetColors(Color.red,Color.red);
line.SetPosition(pointList.Count - 1, (Vector3)pointList [pointList.Count - 1]);
}
}
}
// Following method creates line runtime using Line Renderer component
private void createLine()
{
line = new GameObject("Line").AddComponent<LineRenderer>();
line.material = new Material(shader);// shader = Particles/Additive
pointList = new List<Vector3> ();
line.SetWidth(0.1f,0.1f);
line.SetColors(Color.red,Color.green);
}
}
Is it perhaps a matter of shaders? Could change the shape of the segment to a rectangle?