Home>
First create a rawimage, then add a linerenderer component to this image, and then build a shader.Change the shader of the shader to particles/additive, drag the shader to materials/element 0 of the Linerenderer component (you can also drag it), and finally drag the code to the empty objectThe target of the code is rawimage, the following code
using system.collections;
using system.collections.generic;
using unityengine;
public class huaxian:monobehaviour
{
private gameobject clone;
private linerenderer line;
int i;
//with a Linerender object
public gameobject target;
void start ()
{
debug.log ("Please start writing");
}
//update is called once per frame
void update ()
{
if (input.getmousebuttondown (0))
{
//Instantiate the object
clone=(gameobject) instantiate (target, target.transform.position, quaternion.identity);
//Get the Linerender component on this object
line=clone.getcomponent<linerenderer>();
//Set the start and end colors
line.setcolors (color.red, color.blue);
//Set the start and end width
line.setwidth (0.2f, 0.1f);
//count
i=0;
}
if (input.getmousebutton (0))
{
//Detect every frame,The longer you hold down the mouse,The more counts
i ++;
//Set the number of vertices
line.setvertexcount (i);
//Set the vertex position (the index of the vertex,Convert the screen coordinates of the mouse click to world coordinates)
line.setposition (i-1, camera.main.screentoworldpoint (new vector3 (input.mouseposition.x, input.mouseposition.y, 15)));
}
}
}
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs