怎么在团结中利用LineRenderer绘制两点之间的直线

  介绍

这篇文章将为大家详细讲解有关怎么在团结中利用LineRenderer绘制两点之间的直线,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

private  LineRenderer 行;//画线   时间=line  this.gameObject.AddComponent ();//只有设置了材质,改变颜色才有作用   时间=line.material  new 材料(Shader.Find(“粒子/Additive"));   line.SetVertexCount(2);//设置两点   line.SetColors (Color.yellow, Color.red);,//设置直线颜色   line.SetWidth (0.01 0.01 f, f);//设置直线宽度//设置指示线的起点和终点   line.SetPosition (0,, initPosition);   line.SetPosition (1, newPosition);

绘制圆

下面是以物体位置为圆心,半径为R,在xz平面上的画圆

, public  float  R;//半径   ,public  int  N;//不要超过45   ,line.SetVertexCount (N + 1);//这里要加1,达成闭合曲线   ,for  (int 小姐:=,0;,小姐:& lt;, N  +, 1;,我+ +)   {   float 才能;x =, R  *, Mathf.Cos ((360,/, N  *, i), *, Mathf.Deg2Rad), +, transform.position.x;,//确定x坐标   float 才能;z =, R  *, Mathf.Sin ((360,/, N  *, i), *, Mathf.Deg2Rad), +, transform.position.z;,//确定z坐标   line.SetPosition才能(我,new  Vector3 (transform.position.y, x, z)),,,,,,,,,,   }

<>强补充:统一通过LineRenderer组件画线段

怎么在团结中利用LineRenderer绘制两点之间的直线

using  System.Collections;   using  System.Collections.Generic;   using  UnityEngine,   时间:public  class  DrawLineByMouse  MonoBehaviour  {,   ,,,//画线组件预制体   ,,,public  Transform  gestureOnScreenPrefab;,   ,,,private  int  strokeId =, 1,,   ,,,private  Vector3  virtualKeyPosition =, Vector2.zero;   ,,,private  Rect  drawArea;   ,,,private  RuntimePlatform 平台;   ,,,private  int  vertexCount =, 0;,   ,,,private  List, gestureLinesRenderer =, new  List ();   ,,,private  LineRenderer  currentGestureLineRenderer;,   ,,,//GUI   ,,,private  string 消息=皐hat  is 却;能够吗?“   ,,,private  bool 识别;   ,,,private  string  newGestureName =,““,   ,,,void 开始()   ,,,{   ,,,,,,,platform =, Application.platform;   ,,,,,,,drawArea =, new 矩形(0,0,Screen.width 作用;Screen.width /, 3, Screen.height);   ,,,},   ,,,void 更新()   ,,,{,   ,,,,,,,if  (platform ==, RuntimePlatform.Android  | |, platform ==, RuntimePlatform.IPhonePlayer)   ,,,,,,,{   ,,,,,,,,,,,if  (Input.touchCount 祝辞,0)   ,,,,,,,,,,,{   ,,,,,,,,,,,,,,,virtualKeyPosition =, new  Vector3 (Input.GetTouch .position.x (0), Input.GetTouch (0) .position.y);   ,,,,,,,,,,,}   ,,,,,,,}   ,,,,,,,   ,,,,,,,{   ,,,,,,,,,,,if  (Input.GetMouseButton (0))   ,,,,,,,,,,,{   ,,,,,,,,,,,,,,,virtualKeyPosition =, new  Vector3 (Input.mousePosition.y Input.mousePosition.x也);   ,,,,,,,,,,,}   ,,,,,,,}   ,   ,,,,,,,if  (drawArea.Contains (virtualKeyPosition))   ,,,,,,,{   ,   ,,,,,,,,,,,if  (Input.GetMouseButtonDown (0))   ,,,,,,,,,,,{   ,,,,,,,,,,,,,,+ + strokeId;   ,   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

怎么在团结中利用LineRenderer绘制两点之间的直线