Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C# by nhono99 ( 6 years ago )
private Vector3 initialPos;
private Vector3 finalPos;
// Update is called once per frame
void Update () {
if(Input.GetMouseButtonDown(0)){
print(Input.mousePosition);
initialPos = Input.mousePosition;
print("initial to screen" + Camera.main.ScreenPointToRay(initialPos).origin);
}
if (Input.GetMouseButtonUp (0)) {
print(Input.mousePosition);
finalPos = Input.mousePosition;
print("final to screen" + Camera.main.ScreenPointToRay(finalPos).origin);
DrawLine (Camera.main.ScreenPointToRay(initialPos).origin , Camera.main.ScreenPointToRay(finalPos).origin, Color.red, 100f);
}
}
void DrawLine(Vector3 start, Vector3 end, Color color, float duration = 0.2f)
{
start.z = 0;
end.z = 0;
GameObject myLine = new GameObject();
myLine.transform.position = start;
myLine.AddComponent<LineRenderer>();
LineRenderer lr = myLine.GetComponent<LineRenderer>();
lr.material = new Material(Shader.Find("Particles/Alpha Blended Premultiply"));
lr.SetColors(color, color);
lr.SetWidth(0.1f, 0.1f);
lr.SetPosition(0, start);
lr.SetPosition(1, end);
GameObject.Destroy(myLine, duration);
}
Revise this Paste